简体   繁体   中英

image corner radius only bottom left and right

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

在此输入图像描述

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;

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM