利用UIBezierPath:
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 100, 100) byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(6, 6)].CGPath;
btn.layer.mask = shapeLayer;
byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight 指定哪个角
发现不起作用 使用下面方法。
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.bgBottom jk_setRoundedCorners:(UIRectCornerTopRight|UIRectCornerTopLeft) radius:16];//jk_setRoundedCorners是三方库。jk_
});