美文网首页iOS开发拾碎
iOS view的单个或多个圆角切割

iOS view的单个或多个圆角切割

作者: 王加水 | 来源:发表于2019-06-01 16:09 被阅读0次
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.testImgV.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(100,100)];
    CAShapeLayer *layer = [[CAShapeLayer alloc] init];
    layer.frame = self.testImgV.bounds;
    layer.path = path.CGPath;
    self.testImgV.layer.mask = layer;
    
    
    + (instancetype)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;
    
    //上述方法中的corner参数设置需要变化的角
    typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
        UIRectCornerTopLeft     = 1 << 0,    //上左
        UIRectCornerTopRight    = 1 << 1,    //上右
        UIRectCornerBottomLeft  = 1 << 2,    //下左
        UIRectCornerBottomRight = 1 << 3,    //下右
        UIRectCornerAllCorners  = ~0UL
    };
    
    

    相关文章

      网友评论

        本文标题:iOS view的单个或多个圆角切割

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