用贝赛尔曲线把图片, 按钮, label 绘成圆 或圆角矩形

    //创建圆形遮罩,把用户头像变成圆形

/*

*CGPointMake(35, 35)  是绘图的中心点,  如果想把控件居中绘圆, 一般用控件的中心点,   radius 是圆半径   startAngle是圆周 圆的一周就是2*m_pi

*/

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

    

    //创建圆角矩形遮罩,把用户头像变成圆角矩形

//    UIBezierPath* path =[UIBezierPath bezierPathWithRoundedRect:self.d_teacherIcon.frame cornerRadius:10];

    CGRect rect = self.d_teacherIcon.frame;// button ,imageView, label 等控件的尺寸

/*

*CGRectMake(0, 0, rect.size.width, rect.size.height)   , 0,0 是绘图的左上角坐标,  width, height 是绘图的宽高,10 是圆角

*/

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, rect.size.width, rect.size.height) cornerRadius:10];

    

    

    CAShapeLayer* shape = [CAShapeLayer layer];

    shape.path = path.CGPath;

    self.d_teacherIcon.layer.mask = shape;

    

转载于:https://www.cnblogs.com/balopy/p/5566318.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值