您的位置:首页 > 其它

处理imageView圆角

2016-09-07 16:18 295 查看
@implementation
UIImage (Extension)

- (UIImage
*)circleImage

{

   
// NO代表透明

   
UIGraphicsBeginImageContextWithOptions(self.size,

NO,

0.0);

   

   
//
获得上下文

   
CGContextRef
ctx =
UIGraphicsGetCurrentContext();

   

   
//
添加一个圆

   
CGRect
rect =
CGRectMake(0,

0,

self.size.width,

self.size.height);

   
CGContextAddEllipseInRect(ctx, rect);

   

   
//
裁剪

   
CGContextClip(ctx);

   

   
//
将图片画上去

    [self

drawInRect:rect];

   

   
UIImage
*image =
UIGraphicsGetImageFromCurrentImageContext();

   

   
UIGraphicsEndImageContext();

   

   
return image;
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: