您的位置:首页 > 移动开发 > IOS开发

IOS方形头像如何变成圆形

2015-05-17 16:34 225 查看
方法一:直接使用UIView对应图层的cornerRadius

self.layer.cornerRadius = CGRectGetWidth(self.bounds)/2.f;

self.clipsToBounds = YES;

方法二:使用图层遮罩

   CAShapeLayer* mask = [CAShapeLayer layer];

CGFloat width = self.frame.size.width;

UIBezierPath* path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(width/2,width/2) radius:width /2 startAngle:0 endAngle:2*M_PI clockwise:YES];

mask.path = path.CGPath;

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