how to set cornerRadius for only bottom-left,bottom-right and top-left corner of a UIView?

前端 未结 10 1169
Happy的楠姐
Happy的楠姐 2020-12-04 06:49

Is there a way to set cornerRadius for only bottom-left,bottom-right and top-left corner of a UIView?

I tried the following, but it ended up making the view disappea

10条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 07:11

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

提交回复
热议问题