How set swift 3 UITextField border color?
Try to use this, It might be helpful to you
let myColor : UIColor = UIColor( red: 0.5, green: 0.5, blue:0, alpha: 1.0 )
myTextField.layer.masksToBounds = true
myTextField.layer.borderColor = myColor.CGColor
myTextField.layer.borderWidth = 2.0
You also need to set border width
, because your border color is set already but your default border width is 0.0 so you can't see it.
So, set border width something like,
email.layer.borderWidth = 1.0
Update :
Your code should be like,
@IBOutlet weak var email: UITextField!
@IBOutlet weak var pass: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let myColor = UIColor.white
email.layer.borderColor = myColor.cgColor
pass.layer.borderColor = myColor.cgColor
email.layer.borderWidth = 1.0
pass.layer.borderWidth = 1.0
}
Use the below code in swift 3
:
in view did load
outer_line.layer.borderWidth = 1
outer_line.layer.borderColor = UIColor.lightGray.cgColor
I think you should first provide a borderWidth
@IBOutlet weak var email: UITextField!
@IBOutlet weak var pass: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let myColor : UIColor = UIColor.white()
email.layer.borderWidth = 1
email.layer.borderColor = myColor.cgColor
pass.layer.borderColor = myColor.cgColor
}
and then set a color :)