使用CAShapeLayer改变layer的mask实现view某个角的圆角效果

 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, width, 20)     byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight    cornerRadii:CGSizeMake(10,10)];
        maskPath.lineWidth=0.5f;
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = CGRectMake(0, 0, width, 20) ;
        maskLayer.path = maskPath.CGPath;
        _discountLabel.layer.mask = maskLayer;
        _discountLabel.attributedText = discountVal;
        _discountTipLabel.text = _data.discountTip;

  

posted @ 2018-05-18 17:51  一坨☁️  阅读(248)  评论(0编辑  收藏  举报