繁体   English   中英

如何更改圆形按钮上的边框颜色 (Swift)

[英]How change border color on round button (Swift)

我有四个按钮。

并且两个按钮有圆角(1-(top Left, bottom Left),4-(top Right, bottom Right))

如何更改图像上的边框颜色。

// Right Button
let T1 = UIBezierPath(roundedRect:Delete.bounds, byRoundingCorners:[.topRight, .bottomRight], cornerRadii: CGSize(width: 15, height:  15))
    let maskLayer = CAShapeLayer()
    maskLayer.path = T1.cgPath
    Delete.layer.mask = maskLayer
// Left Button
let T2 = UIBezierPath(roundedRect:Copy.bounds, byRoundingCorners:[.topLeft, .bottomLeft], cornerRadii: CGSize(width: 15, height:  15))
    let maskLayer2 = CAShapeLayer()
    maskLayer2.path = T2.cgPath
    Copy.layer.mask = maskLayer2

将您的UIView “containerView”添加为IBOutlet并设置您的containerView.layer.borderWidth = yourDesiredWidth并设置containerView.layer.borderColor = yourNeededColor.cgColor

UIButton.layer.cornerRadiusUIButton.layer.borderColorUIButton.layer.borderWidth layerUIView一个属性,所以你几乎可以用它自定义任何视图。

button.layer.borderColor = CGColor(srgbRed: 255/255, green: 126/255, blue: 121/255, alpha: 1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM