3

I am new in iOS and I am facing problem regarding to curve UIView. I want to curve the radius of the top of UIView like this in the Image

enter image description here

As you can see the screenshot of my work view.

I am using code like this

UIBezierPath *maskPath = [UIBezierPath
                          bezierPathWithRoundedRect:ViewSwapMyWork.bounds
                          byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                          cornerRadii:CGSizeMake(70, 70)
                          ];

CAShapeLayer *maskLayer = [CAShapeLayer layer];

maskLayer.frame = ViewSwapMyWork.bounds;
maskLayer.path = maskPath.CGPath;

ViewSwapMyWork.layer.mask = maskLayer; 
halfer
  • 19,824
  • 17
  • 99
  • 186
Muju
  • 884
  • 20
  • 54
  • you want to only curve upper half of the view or full round shape ? – Hitesh Sultaniya Dec 13 '17 at 05:21
  • @HiteshSultaniya Only upper half of the view. – Muju Dec 13 '17 at 05:23
  • Possible duplicate of [How can you make a UIView with rounded top corners and square bottom corners](https://stackoverflow.com/questions/6499663/how-can-you-make-a-uiview-with-rounded-top-corners-and-square-bottom-corners) – sam_smith Dec 13 '17 at 05:33

1 Answers1

4

First your view should have the same height and width means it should be square, then you can do like this,

[ViewSwapMyWork.layer setCornerRadius:ViewSwapMyWork.frame.size.width/2];
[ViewSwapMyWork.layer setMasksToBounds:YES];
Hitesh Sultaniya
  • 929
  • 1
  • 7
  • 12