Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to change border color of text field in swift

I am trying to change border color of a text label, i cant find any option to change it in Main(base) and the code i am using in viewController is:

`

              import UIKit

              class ViewController: UIViewController {

               @IBOutlet weak var textsa: UITextField!
               override func viewDidLoad() {
               super.viewDidLoad()
               textsa.layer.backgroundColor = CGColor(red: 23, green: 23, blue: 23, alpha: 12.3)
           } 


       }

`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to set borderColor and borderWidth for textfield layer.

        textsa?.layer.borderColor = UIColor.red.cgColor
        textsa?.layer.borderWidth = 2.0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading