iOS UIImage设置圆角
新建UIImage分类如下: @interface UIImage (RoundedRectImage) - (UIImage *)setRoundedCorners:(CGFloat)radius andSize:(CGSize)size; @end #import "UIImage+RoundedRectImage.h" @implementation UIImage (RoundedRectImage) - (UIImage *)setRoundedCorners:(CGFloat)radius andSize:(CGSize)size{ CGRect rect = CGRectMake(0, 0, size.width, size.height); UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); CGContextRef ctx = UIGraphicsGetCurrentContext(); UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(radius,