[英]CGImageRef and drawing layers
我有以下代碼:
CGDataProviderRef provider = CGDataProviderCreateWithFilename([myFile UTF8String]);
CGImageRef img = CGImageCreateWithJPEGDataProvider(provider, NULL, true, kCGRenderingIntentDefault);
后來我以這種方式將CGImageRef加載到UIImage中:
UIImage *uiImage = [[UIImage alloc] initWithCGImage:destImage];
我想在該圖片上畫一個圓圈。 關鍵是圓的移動,因此必須刪除並重畫。 我想最好的方法是使用圖層,所以我的問題是:如何在該代碼中添加一個圖層並在其上畫一個圓? 以后如何重置圖層並重畫該圓圈?
謝謝!
您將要使用UIImageView,然后向該視圖添加單獨的圖層。 如果您的圖層[circle]移動,只需將其position屬性設置為新的中心; 視圖系統將負責重新組合所有內容。
為了使您的圈子顯示在圖層中,可以使用固定圖像,子類CALayer並覆蓋drawInContext:,或者設置委托並實現drawLayer:inContext:。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.