How to change UITextField keyboard type to email in Swift

user1898829 picture user1898829 · Oct 16, 2014 · Viewed 50.2k times · Source

In objective-c I can just say the following.

[self.promoTextField setKeyboardType:UIKeyboardTypeEmailAddress];

I tried googling it but just get ways to do it in objective-c.

Answer

Pintouch picture Pintouch · Oct 16, 2014

Try this :

Swift 3

self.promoTextField.keyboardType = UIKeyboardType.emailAddress

Swift < 3

self.promoTextField.keyboardType = UIKeyboardType.EmailAddress