首页 > 移动平台 > 详细

IOS方形头像如何变成圆形

时间:2015-05-17 18:11:10      阅读:331      评论:0      收藏:0      [点我收藏+]

方法一:直接使用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;

IOS方形头像如何变成圆形

原文:http://www.cnblogs.com/guoxiaoqian/p/4509953.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!