-(
void
)redrawImage
{
[_imageView setImage:[
UIImage
imageNamed:@
"your image goes here"
]];
CGFloat size = [
self
.radius floatValue];
CGContextRef context = CGBitmapContextCreate(
NULL
,
self
.view.bounds.size.width,
self
.view.bounds.size.height, 8, 4 *
self
.view.bounds.size.width, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedFirst);
CGContextAddArc(context, 320/2, 460/2, size, 0, 2*M_PI, 0);
CGContextClosePath(context);
CGContextClip(context);
CGContextDrawImage(context,
self
.view.bounds, _imageView.image.CGImage);
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage
*newImage = [
UIImage
imageWithCGImage:imageMasked];
CGImageRelease(imageMasked);
[_imageView setImage:newImage];
UIGraphicsEndImageContext
();
}
参考地址:http://bbs.csdn.net/topics/390412534