在我的Xamarin.IOS visual studio項目中,我想在UIImageView中使用Vector pdf圖像。但我無法直接在故事板設計器中添加矢量圖像(也試過拖放)。在Xamarin IOS中使用Vector pdf圖像
有沒有辦法在xamarin IOS中使用Vector pdf圖像?任何樣品都會很有幫助。
謝謝。
在我的Xamarin.IOS visual studio項目中,我想在UIImageView中使用Vector pdf圖像。但我無法直接在故事板設計器中添加矢量圖像(也試過拖放)。在Xamarin IOS中使用Vector pdf圖像
有沒有辦法在xamarin IOS中使用Vector pdf圖像?任何樣品都會很有幫助。
謝謝。
是的,正如lowleetak所說,我們需要首先將pdf文件添加到資產中。
Xamarin教程here,只需按照步驟操作,很簡單。
編輯:
沒有選項,選擇屬性檢查器在Visual Studio中設置擴展到單矢量。有沒有替代方案?
AFAIK,沒有選項來設置矢量的比例尺,也許你可以在生成pdf文件時設置這個屬性。
我想處理點擊事件捕捉圖像X Y座標在C#中。有沒有辦法做到這一點?
覆蓋觸摸事件。文檔here。
代碼:
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
var touch = touches.AnyObject as UITouch;
CGPoint point = touch.GetPreciseLocation(yourImage);
}
更新:
這是制約
謝謝科爾。我能夠使用添加矢量圖像。 但問題在於捕獲圖像的X Y座標。如果我使用Touches/LocationInView - 它給出了屏幕的座標。而我想要UIImageView中的矢量圖像的XY點。有什麼辦法可以得到這個? – Praddy
@Praddy將偵測視圖設置爲您的圖像,它會自動計算圖像內部的座標。 CGPoint point = touch.GetPreciseLocation(yourImage); –
我的觸摸, public override void TouchesBegan(NSSet touches,UIEvent evt) {base.TouchesBegan(touches,evt); UITouch touch = touches.AnyObject作爲UITouch; string pos =「X」+ touch.GetPreciseLocation(VectorImage).X +「Y」+ touch.GetPreciseLocation(VectorImage).Y; } 在我的情況下,對於不同的屏幕大小,它應該返回圖像的相同X Y座標。例如:Iphone 5s和Iphone6中的相同圖像在同一點觸摸時應返回相同的XY。 但是,此觸摸從視圖位置的左側和頂部返回實際XY。 – Praddy