Hello! Trying to make rounded edges at UIView, here’s how I do it.

-(void)makeRoundedCornerRadius:(RoundedCorner)side withRadius:(CGFloat)radius forView:(UIView*)view{ UIBezierPath *maskPath; if (side == RoundedCornerTOP){ maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(radius, radius)]; } else if (side == RoundedCornerLEFT){ maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft| UIRectCornerBottomLeft cornerRadii:CGSizeMake(radius, radius)]; } else if (side == RoundedCornerRIGHT){ maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomRight| UIRectCornerTopRight cornerRadii:CGSizeMake(radius, radius)]; } else if (side == RoundedCornerBOTTOM){ maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft| UIRectCornerBottomRight cornerRadii:CGSizeMake(radius, radius)]; } CAShapeLayer *maskLayer = [CAShapeLayer new]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer; } 

In this case, only the left corners are rounded, and on the right ones this does not apply. What to do?

  • everything worked fine for me. try to reproduce in an empty project - Max Mikheyenko

2 answers 2

The problem was that they rounded out before the size became "normal." Storyboard width is 600px first

    In the method you have to check if - else. That means you can round off only one side.

    You need to add the macro RoundedCornerAllCorners to NS_ENUM or NS_OPTIONS and in the method execute:

     if (side & RoundedCornerAllCorners) { maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft| UIRectCornerBottomRight| UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(radius, radius)]; } 

    Either change to if (side & RoundedCornerTOP) { etc, to transfer to the RoundedCornerTOP method | RoundedCornerBOTTOM

    I hope this helps you.