如何在Swift 3中更改所有TextField边框颜色 [英] How to change all TextField border colour in Swift 3
本文介绍了如何在Swift 3中更改所有TextField边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Swift 3中更改所有TextField边框颜色 我建立了一个iPad应用程序. 我的.xib文件中有很多TextField,现在我想更改边框颜色,但是要写特定的textfield这么多行,因此有任何排序方式吗?
How to change all TextField border colour in Swift 3 i build one iPad application. i have many TextField in my .xib file and now i want to change border colour but it so many line to write particular textfield so any sort way for this ?
推荐答案
添加此扩展名可为项目中的所有文本字段创建边框.
Add this extension to create border for all textfields in your project.
extension UITextField
{
open override func draw(_ rect: CGRect) {
self.layer.cornerRadius = 3.0
self.layer.borderWidth = 1.0
self.layer.borderColor = UIColor.lightGray.cgColor
self.layer.masksToBounds = true
}
}
这篇关于如何在Swift 3中更改所有TextField边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文