两个按钮有圆角(1-(左上,左下),4-(右上,右下))。
如何在图像上更改边框颜色。
// 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
答案 0 :(得分:4)
添加您的UIView
" containerView"设为IBOutlet
并设置containerView.layer.borderWidth = yourDesiredWidth
并设置containerView.layer.borderColor = yourNeededColor.cgColor
答案 1 :(得分:2)
UIButton.layer.cornerRadius
,UIButton.layer.borderColor
和UIButton.layer.borderWidth
。 layer
是UIView
的属性,因此您可以使用它自定义任何视图。
答案 2 :(得分:1)
button.layer.borderColor = CGColor(srgbRed: 255/255, green: 126/255, blue: 121/255, alpha: 1)