ios圆角

iOS UIImage设置圆角

元气小坏坏 提交于 2020-01-26 10:34:34
新建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,