前言:ios开发中经常遇到一个view上只要两个圆角的情况。
1.切四个圆角的情况
view.layer.cornerRadius = 12;
view.layer.masksToBounds = YES;
2.单独切圆角的情况,比如切左上、右上两个圆角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH, 1000) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bottomView.bounds;
maskLayer.path = maskPath.CGPath;
self.bottomView.layer.mask = maskLayer;
解决!
查看更多!