方法1: 修改UIImageView的layer
imageView.layer.cornerRadius = self.size.width/2;
imageView.clipsToBounds = YES;
方法2: 裁剪image
#import "UIImage+SRExtension.h"
@implementation UIImage (SRExtension)
-(UIImage *)circleImage{
// NO:代表透明
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0);
//獲取圖片上下文
CGContextRef ref = UIGraphicsGetCurrentContext();
//添加一個園
CGRect rect = CGRectMake(0, 0, self.size.width,self.size.height);
CGContextAddEllipseInRect(ref, rect);
//裁剪
CGContextClip(ref);
//畫上去
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者