标签:
//----------第一种方法-------------------
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.layer.contents = [UIImage imageNamed:@"zsy.jpg"];
//// _img.image = [UIImage imageNamed:@"zsy.jpg"];
// [_img.layer needsDisplay];
//
//----------第二种方法(优化了性能)-------------------
// _img.layer.shouldRasterize = YES;
// _img.layer.rasterizationScale = self.view.window.screen.scale;
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.image = [UIImage imageNamed:@"zsy.jpg"];
//
//----------第三种方法(优化了性能)-------------------
//获取图片
UIImage *imge = [UIImage imageNamed:@"zsy.jpg"];
//Creates a bitmap-based graphics context
UIGraphicsBeginImageContextWithOptions(_img.bounds.size, NO, 1.0);
//Creates and returns a new UIBezierPath objec
[[UIBezierPath bezierPathWithRoundedRect:_img.bounds cornerRadius:150]addClip];
// [self.view.layer drawInContext:<#(CGContextRef)#>];
[imge drawInRect:_img.bounds];
_img.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
标签:
原文地址:http://www.cnblogs.com/plummithly/p/4616481.html