简体   繁体   中英

How change border color on round button (Swift)

i have four button.

And two button have round corner (1-(top Left, bottom Left),4-(top Right, bottom Right)) .

How can i change border color how on image.

// 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.cornerRadius , UIButton.layer.borderColor , and UIButton.layer.borderWidth . layer is a property of UIView , so you can pretty much customize any view with it.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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