如何批量给uibutton设置边框圆弧等

如何批量给uibutton设置边框圆弧等,第1张

方法如下:

UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]

signBtn.frame = CGRectMake(0, 0, 80, 40)

[signBtn.layer setMasksToBounds:YES]

[signBtn.layer setCornerRadius:10.0]

//设置矩形四个圆角半径

[signBtn.layer setBorderWidth:1.0]

//边框宽度

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB()

CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 })

[signBtn.layer setBorderColor:colorref]

//边框颜色.

刚刚找到答案:

UIColor *taskColor = [UIColor colorWithRed:0.98f green:0.92f blue:0.80f alpha:1.0f]

UIButton *taskBtn = [[UIButton alloc] initWithFrame:CGRectMake(40, 150, 280, 160)]

taskBtn.backgroundColor = taskColor

CALayer *bottomBorder = [CALayer layer]

float height=taskBtn.frame.size.height-1.0f

float width=taskBtn.frame.size.width

bottomBorder.frame = CGRectMake(0.0f, height, width, 1.0f)

bottomBorder.backgroundColor = [UIColor redColor].CGColor

[taskBtn.layer addSublayer:bottomBorder]


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11439569.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存