I made a textfield in IB with the following settings:
The result is that the inside of the field is 15%, but there's a very thin visible border that isn't, and I want that removed. I've tried doing it in code like this:
textField.borderStyle = UITextBorderStyle.None
textField.layer.cornerRadius = 10
textField.layer.borderColor = UIColor(red:1.0,green:1.0,blue:1.0,alpha:0.15).CGColor
But this just puts the border on the inside covering the actual textfield.
Textfield:
Try to add this:
textField.layer.borderWidth = 0
Additionally, from the screenshot, it seems that textField.layer.cornerRadius = 10
is ignored, make sure that your textField
property is connected to the actual UITextField
.
The simplest approach to achieving a border-free textfield is to change the style of the textfield.
Example Code
// Reference
@IBOutlet var tf: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Email TextField: no border
tf.borderStyle = .none
}
The Result
Swift3
passwordTF.layer.borderColor = UIColor.clear.cgColor
For me its working as well as
mobileNumberTF.borderStyle = .none
Try this one
self.nameTextField.borderStyle = UITextBorderStyleNone;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.