开发者

CGImageRef and drawing layers

I have this code:

CGDataProviderRef provider = CGDataProviderCreateWithFilename([myFile UT开发者_Python百科F8String]);
CGImageRef img = CGImageCreateWithJPEGDataProvider(provider, NULL, true, kCGRenderingIntentDefault);

Later I load that CGImageRef in a UIImage this way:

UIImage *uiImage = [[UIImage alloc] initWithCGImage:destImage];

I'd like to draw a circle over that Image. The point is the circle moves so it has to be deleted and redraw. I guess the best way of accomplishing this is with layers so my question is: How can I add a layer to that code and draw a circle on it? How can I later reset the layer and redraw that circle?

Thank you!


You'll want to use a UIImageView, and then add a separate layer to that view. If your layer [circle] moves, just set its position property to the new center; the view system will take care of re-compositing everything.

To get your circle to show up in the layer, you can either use a fixed image, subclass CALayer and override drawInContext:, or set the delegate and implement drawLayer:inContext:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜