美文网首页
iOS 签到按钮的左边半圆方法

iOS 签到按钮的左边半圆方法

作者: 纵昂 | 来源:发表于2019-09-26 14:32 被阅读0次
App上会有签到的领积分的小按钮,左边是半圆 IMG_1884.png
#pragma mark - 签到 sigBtn
    _sigBtn = [[UIButton alloc] initWithFrame:CGRectMake(HJWIDTH/3*2-14, (90-70)/2+13, HJWIDTH/3, 40)];
    [_sigBtn setImage:[UIImage imageNamed:@"积分"] forState:UIControlStateNormal];
    [_sigBtn addTarget:self action:@selector(sButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [_sigBtn setBackgroundColor:App_shoukeColor];
//    实现按钮左边半圆
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_sigBtn.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(_sigBtn.frame.size.height/2,_sigBtn.frame.size.height/2)];//圆角大小
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = _sigBtn.bounds;
    maskLayer.path = maskPath.CGPath;
    _sigBtn.layer.mask = maskLayer;
    
    [zhuView addSubview:_sigBtn];

效果如下:


屏幕快照 2019-09-26 14.31.51.png

相关文章

网友评论

      本文标题:iOS 签到按钮的左边半圆方法

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