图片圆角

- (UIImage *)imageWithCornerRadius:(CGFloat)radius {
CGRect rect = (CGRect){0.f, 0.f, self.size};
 
UIGraphicsBeginImageContextWithOptions(self.size, NO, UIScreen.mainScreen.scale);
CGContextAddPath(UIGraphicsGetCurrentContext(),
 [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius].CGPath);
CGContextClip(UIGraphicsGetCurrentContext());
 
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
 
UIGraphicsEndImageContext();
 
return image;
}
posted @ 2017-02-17 15:49  xiaoxiaoxigua  阅读(110)  评论(0编辑  收藏  举报