I'm tried to draw a bottom curve on UIimageview using uibezierpath. I don't know how to do that?
- (void)setMaskTo:(UIView*)view byRoundingCorners:
(UIRectCorner)corners
{
UIBezierPath *rounded = [UIBezierPath
bezierPathWithRoundedRect:view.bounds
byRoundingCorners:corners
cornerRadii:CGSizeMake(200.0, 200.0)];
CAShapeLayer *shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
view.layer.mask = shape;
}
i already tried like this https://i.sstatic.net/lcAlN.jpg
I expect the output of https://i.sstatic.net/uWBKi.jpg
This should help you get going...
With a UIBezierPath
:
A
B
with control point C
D
E
Here's a simple UIView
subclass:
@implementation BottomCurveView
- (void)layoutSubviews {
[super layoutSubviews];
CGRect rect = self.bounds;
CGFloat y = rect.size.height - 80.0;
CGFloat curveTo = rect.size.height;
UIBezierPath *myBez = [UIBezierPath new];
[myBez moveToPoint:CGPointMake(0.0, y)];
[myBez addQuadCurveToPoint:CGPointMake(rect.size.width, y) controlPoint:CGPointMake(rect.size.width / 2.0, curveTo)];
[myBez addLineToPoint:CGPointMake(rect.size.width, 0.0)];
[myBez addLineToPoint:CGPointMake(0.0, 0.0)];
[myBez closePath];
CAShapeLayer *maskForPath = [CAShapeLayer new];
maskForPath.path = myBez.CGPath;
[self.layer setMask:maskForPath];
}
@end
That produces the above image for a 200-pt tall view.