UIButton
提供的创建圆角按钮方法UIRectCornerTopLeft
UIRectCornerBottomLeft
UIRectCornerTopRight
UIRectCornerBottomRight
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 60, 80, 40)];button.backgroundColor = [UIColor orangeColor];[self.view addSubview:button]; //这里设置的是左上和左下角UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(8, 8)];CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];maskLayer.frame = button.bounds;maskLayer.path = maskPath.CGPath;button.layer.mask = maskLayer;效果图
总结
IOS设置按钮为圆角的方法到这就结束了,大家都学会了吗?希望这篇文章对大家的开发能有一定的帮助,如果有疑问大家可以留言交流。谢谢大家对脚本之家的支持。