/
UIImage圆角

UIImage圆角

- (UIImage *)imageWithCornerRadius:(float)cornerRadius {
    
    CGRect frame = CGRectMake(0, 0, self.size.width, self.size.height);
    
    // Begin a new image that will be the new image with the rounded corners
    // (here with the size of an UIImageView)
    UIGraphicsBeginImageContextWithOptions(self.size, NO, 1.0);
    
    // Add a clip before drawing anything, in the shape of an rounded rect
    [[UIBezierPath bezierPathWithRoundedRect:frame
                                cornerRadius:cornerRadius] addClip];
    // Draw your image
    [self drawInRect:frame];
    
    // Get the image, here setting the UIImageView image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    // Lets forget about that we were drawing
    UIGraphicsEndImageContext();
    
    return image;
}

Related content

UIEdgeInsets
UIEdgeInsets
More like this
UIGetScreenImage
UIGetScreenImage
More like this
UIColor to UIImage
UIColor to UIImage
More like this
Image Dimension
Image Dimension
More like this
谈谈iOS Animation
谈谈iOS Animation
More like this
iOS生产力之小工具合集
iOS生产力之小工具合集
More like this