ios实现圆形相框

-(void)redrawImage
{
    //set the original image first
    [_imageView setImage:[UIImage imageNamed:@"your image goes here"]];
 
    CGFloat size = [self.radius floatValue];
    CGContextRef context = CGBitmapContextCreate(NULLself.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

你可能感兴趣的:(ios,imageview,圆形相框)