您的位置:首页 > 其它

设置图片圆角

2015-07-02 16:46 232 查看
//----------第一种方法-------------------

// _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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: