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

2019-09-26  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读