如何为 1px 宽的 UIButton 添加黑色轮廓?

Tho*_*hor 2 xcode uibutton ios swift

我是 xcode 新手,想向 1px 宽的 UIButton 添加黑色轮廓。我已经在 Xcode 中的检查器中搜索了 UIButton,但找不到该设置。我已经阅读了 UIButton 的文档,但它似乎没有这个特殊的功能。是否可以为 UIButton 添加彩色轮廓?

Way*_*ins 5

在 viewDidLoad() 中我输入:

self.buttonName.layer.borderWidth = 1

self.buttonName.layer.borderColor = UIColor.whiteColor().CGColor
Run Code Online (Sandbox Code Playgroud)