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

前端 未结 10 1170
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:28

    hope this will help you

    your above code running perfectly on my machine , may be you set CAShapeLayer frame equal to your view frame due to which your view will disappear but i am not seeing this line in your code ,so please check your view property and apply below code

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

提交回复
热议问题