美文网首页
Uibutton 一侧圆角裁剪

Uibutton 一侧圆角裁剪

作者: 八百标兵boomboom | 来源:发表于2018-10-22 14:24 被阅读0次

    UIButton * button =[UIButton buttonWithType:UIButtonTypeSystem];
    [self.view addSubview:button];//一定要先添加到视图上
    button.frame=CGRectMake(100, 100, 100, 40);
    button.backgroundColor=[UIColor blueColor];

    UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerTopRight|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer=[[CAShapeLayer alloc]init];
    maskLayer.frame=button.bounds;
    maskLayer.path=maskPath.CGPath;
    button.layer.mask=maskLayer;

    3C01B4BC-7087-4F70-9705-4017FD540275.png

    相关文章

      网友评论

          本文标题:Uibutton 一侧圆角裁剪

          本文链接:https://www.haomeiwen.com/subject/vckgzftx.html