这种方式可以控制四个角的圆角属性。 typedef NS_OPTIONS(NSUInteger, UIRectCorner) { UIRectCornerTopLeft = 1 << 0, UIRectCornerTopRight = 1 << 1, UIRectCornerBottomLeft = 1 << 2, UIRectCornerBottomRight = 1 << 3, UIRectCornerAllCorners = ~0UL }; CGRect rect = CGRectMake(0, 0, ScreenWidth - PADDING *2, 44); CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = rect; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(3, 3)]; maskLayer.path = maskPath.CGPath; cell.maskLayer = maskLayer; |
本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1746342,如需转载请自行联系原作者