Uppercase characters in UItextfield

前端 未结 17 1259
萌比男神i
萌比男神i 2020-12-24 04:34

I have a question about iOS UIKeyboard.

I have a UITextField and I would to have the keyboard with only uppercase characters.<

17条回答
  •  旧巷少年郎
    2020-12-24 05:31

    SwiftUI

    For SwiftUI the Syntax for autocapitalization and Keyboard type selection is:

    TextField("Your Placeholder", text: $emailAddress)
         .keyboardType(.emailAddress)
         .autocapitalization(.none)
    

    You can use the following options for autocapitalization:

    .none //Specifies that there is no automatic text capitalization.
    
    .words //Specifies automatic capitalization of the first letter of each word.
    
    .sentences //Specifies automatic capitalization of the first letter of each sentence.
    
    .allCharacters //Specifies automatic capitalization of all characters, such as for entry of two-character state abbreviations for the United States.
    

提交回复
热议问题