iOS图片裁成圆角
- (UIImage *)circleImage:(UIImage *)image {
// 创建圆形路径
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:rect];
[path addClip];
// 绘制图片
[image drawInRect:rect];
UIImage *circleImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return circleImage;
}
发表回复