UIView半边圆角半边直角

picture.png

如图:

用 UIBezierPath 类的方法可以实现这个效果:

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                           byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft)
                                                 cornerRadii:CGSizeMake(5, 5)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = path.CGPath;
self.layer.mask = maskLayer;

你可能感兴趣的:(UIView半边圆角半边直角)