如何以编程方式设置UIView的自定义边框颜色? [英] How to set the custom border color of UIView programmatically?
本文介绍了如何以编程方式设置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
这篇关于如何以编程方式设置UIView的自定义边框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文