There is no code based approach:
Select the type of text field from the main storyboard view controller in which it is embedded. If you look in the Utilities view, there will be a long list of attributes in Attributes Inspector. Under the heading "Text box" you will find various settings, such as font, alignment, placeholder, etc. When you look down, you will go to 6 drop-down lists called "capitalization" through the "Return Key". When you click on the list called “Return Key”, you will see a list of return keys, including “Search,” “Yahoo,” “Route,” etc. From the list, select the Done keyword. That should do the trick. Image of how it looks in Xcode
Also from apple documentation :
"You configure keyboard attributes directly through the text objects of your application. The UITextField and UITextView classes conform to the UITextInputTraits protocol, which defines properties for keyboard settings. Setting these properties programmatically or in Interface Builder, the inspector window causes the system to display the keyboard of the assigned type."
source share