How to apply corner radius to rectangles drawn by UIBezierPath
suggest changeCorner radius for all 4 edges:
![](/essential/ios/img/44ba9fa248be80e23cc7c861c3aef6fdf63ab7d5.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) cornerRadius: 11];
[UIColor.grayColor setFill];
[rectanglePath fill];
Corner radius for top-left edge:
![](/essential/ios/img/165a1c1ea7d074cc3f76c40f58fabf992d381c53.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerTopLeft cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
Corner radius for top-right edge:
![](/essential/ios/img/3d0bab13238c99dee96459090a47266df5e44f87.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerTopRight cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
corner radius for bottom-left edge:
![](/essential/ios/img/03c589c1fabd1441574290a841516b751ee7e466.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerBottomLeft cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
corner radius for bottom-right edge:
![](/essential/ios/img/cdbd5adbc9f7e87767c822674a3dfe8c0d340c0d.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerBottomRight cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
corner radius for bottom edges:
![](/essential/ios/img/532c847eb99ce98c28389ee9373d67eebc7b8f7c.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
corner radius for top edges:
![](/essential/ios/img/22ea693977295d1d62948ae4cceb7a0bf4369628.png)
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(11, 11)];
[rectanglePath closePath];
[UIColor.grayColor setFill];
[rectanglePath fill];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents