import UIKit
class ViewController:UIViewController,
UITextFieldDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view,typically from a nib.
let rect = CGRect(x:60, y:80, width:200, height:30)
let textField = UITextField(frame:rect)
textField.borderStyle = UITextBorderStyle.roundedRect
textField.placeholder = “Your Email”
textField.autocorrectionType =
UITextAutocorrectionType.no
textField.returnKeyType = UIReturnKeyType.done
textField.clearButtonMode =UITextFieldViewMode.whileEditing
textField.keyboardType =UIKeyboardType.emailAddress
textField.keyboardAppearance =UIKeyboardAppearance.dark
textField.delegate = self
self.view.addSubview(textField)
}
func textFieldShouldReturn(_ textField:UITextField)-> Bool {
textField.resignFirstResponder()
return true
}
}
//UITextBorderStyle
image.png
//UITextFieldViewMode
image.png
//UIReturnKeyType
image.png
textField.backgroundColor = UIColor.brown
textField.background = UIImage(named:“background”)
textField.isEnabled = false
textField.disabledBackground =UIImage(named:“disabledBackground”)