views:

411

answers:

1

I have this code:

CGDataProviderRef provider = CGDataProviderCreateWithFilename([myFile UTF8String]);
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!

A: 

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:.

Ben Gottlieb