如何以编程方式设置UIView的自定义边框颜色?
问题描述:
我试图在Swift中以编程方式设置UIView的自定义边框颜色。
I am trying to set the custom border color of UIView programmatically in Swift.
答
如果你想要自定义颜色,使用下面的代码......
如果您使用Swift 2.0 -
self.yourView.layer.borderWidth = 1
self.yourView.layer.borderColor = UIColor(red:222/255, green:225/255, blue:227/255, alpha: 1).cgColor
如果你使用Swift 3.1或后者 -
self.yourView.layer.borderWidth = 1
self.yourView.layer.borderColor = UIColor(red:222/255, green:225/255, blue:227/255, alpha: 1).cgColor