佚名通过本文主要向大家介绍了ios button,ios button圆角,3dbutton.dll,button,push button官网等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: iOS 怎么把button的边缘变成虚线
描述:
解决方案1:
描述:
比如这样
解决方案1:
自定义一个Button吧
@implementation CustomButton
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setupLayersWithFrame:frame];
}
return self;
}
- (void)setupLayersWithFrame:(CGRect)frame{
CAShapeLayer * roundedrect = [CAShapeLayer layer];
roundedrect.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
roundedrect.fillColor = [UIColor whiteColor].CGColor;
roundedrect.strokeColor = [UIColor colorWithRed:0.329 green: 0.329 blue:0.329 alpha:1].CGColor;
roundedrect.lineDashPattern = @[@5.5, @4.5];
roundedrect.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, frame.size.width , frame.size.height) cornerRadius:20].CGPath;
[self.layer addSublayer:roundedrect];
}
解决方案2:一个建议:一般这种情况,我们都是用图片的,设置按钮的背景图片就好了。