I want to use round corner style in my UIView, and here is my code:
UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.styleView1.bounds
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(4, 4)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = self.styleView1.bounds;
maskLayer1.path = maskPath1.CGPath;
self.styleView1.layer.borderWidth = 1;
[self.styleView1.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
self.styleView1.layer.mask = maskLayer1;
The effect is like that:
There is blank on the corner, like feather effect in Photoshop.
But what I want is this:
How to make it happen?
2
Answers
If self is a UIViewController or UISplitViewController then self doesn’t have bounds, it’s a controller.
Try this one:
You can set radius for top view as below code check (how to set cornerRadius for only bottom-left,bottom-right and top-left corner of a UIView?) for reference.
and you will get following.