I want to corner radius exact in round shape only bottom corner left and right. I already done it but bottom shape not look like exact round so how can I solve this problem
Asked
Active
Viewed 665 times
1
-
Look in below links [Link1](http://stackoverflow.com/questions/25616382/how-to-set-cornerradius-for-only-bottom-left-bottom-right-and-top-left-corner-of) , [Link2](http://stackoverflow.com/questions/29618760/create-a-rectangle-with-just-two-rounded-corners-in-swift/35621736#35621736) – Gagan_iOS Feb 25 '16 at 10:38
-
View this link http://stackoverflow.com/questions/10167266/how-to-set-cornerradius-for-only-top-left-and-top-right-corner-of-a-uiview maybe it will help full to you. – JigneshP Feb 25 '16 at 10:38
-
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.imageView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = self.imageView.bounds; maskLayer.path = maskPath.CGPath; self.imageView.layer.mask = maskLayer; – Nilesh Parmar Feb 26 '16 at 07:56
-
i used that code but not bottom at round shape..look at my image at botton – Nilesh Parmar Feb 26 '16 at 07:57
-
and when this code run on iphone6 imageview left some space of width at right position.. – Nilesh Parmar Feb 26 '16 at 08:00
2 Answers
3
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.imageView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.imageView.bounds;
maskLayer.path = maskPath.CGPath;
self.imageView.layer.mask = maskLayer;

Inder Kumar Rathore
- 39,458
- 17
- 135
- 184
-
ok i used your code and give CGSizeMake(150.0, 150.0)] but result same look my image at bottom that not exact round shape and when this code run in iphone 6 width and height same it take some space at width. – Nilesh Parmar Feb 26 '16 at 07:53
0
I have the same issues and I solved it like this :
- (void)setMaskTo:(UIView*)view {
CAShapeLayer *rect = [[CAShapeLayer alloc] init];
[rect setFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height/2)];
rect.backgroundColor = ([UIColor grayColor]).CGColor;
UIBezierPath *shape = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,rect.frame.size.height/2,self.view.frame.size.width,self.view.frame.size.height/2)];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = shape.CGPath;
shapeLayer.fillColor = [UIColor grayColor].CGColor;
CAShapeLayer *viewMask = [[CAShapeLayer alloc] init];
[viewMask addSublayer:shapeLayer];
[viewMask addSublayer:rect];
view.layer.mask = viewMask;
}

victor.solonets
- 1
- 2