Specify border radius of UITextField in Swift

If you're using Interface Builder, you can use User Defined Runtime Attributes for the controls you want to modify. At runtime, when the view loads, each attribute you pass a key path for will automatically be set to your value. No need to clutter up your code with little display tweaks.

The picture below should answer your question.

Adding border radius with IB Runtime Attributes


You can use:

nameOfTextField.layer.cornerRadius = 15.0
nameOfTextField.layer.borderWidth = 2.0
nameOfTextField.layer.borderColor = UIColor.red.cgColor