小编典典

如何在 Swift 中使按钮具有圆形边框?

all

我正在使用最新版本的 Xcode 6 中的 swift
构建一个应用程序,并且想知道如何修改我的按钮,以便它可以有一个圆形边框,我可以在需要时自行调整。完成后,如何在不添加背景的情况下更改边框本身的颜色?换句话说,我想要一个没有背景的略圆的按钮,只有一个特定颜色的
1pt 边框。


阅读 109

收藏
2022-05-16

共1个答案

小编典典

使用和。button.layer.cornerRadius_ 请注意,需要 a ,因此您可以说(Swift
3/4):button.layer.borderColor``button.layer.borderWidth``borderColor``CGColor

button.backgroundColor = .clear
button.layer.cornerRadius = 5
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.black.cgColor
2022-05-16