簡體   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