美文网首页
UIView单独设置4个边角的圆角

UIView单独设置4个边角的圆角

作者: ___1o_8o | 来源:发表于2016-08-15 18:01 被阅读296次

在开发中有时会遇到并不需要4个边角都需要设置圆角的情况,我们仅仅只需要上面两个角或者下面两个角等等

不多说 直接上代码:

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

友情提示: 一半圆角的半径数值设为高度或者宽度一半就可以了.

相关文章

网友评论

      本文标题:UIView单独设置4个边角的圆角

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