How to set Keyboard type of TextField in SwiftUI?

后端 未结 7 1412
灰色年华
灰色年华 2021-02-03 19:46

I can\'t seem to find any information or figure out how to set the keyboard type on a TextField for SwiftUI. It would also be nice to be able to enable the secure text property,

相关标签:
7条回答
  • 2021-02-03 20:35

    To create a field where you can enter secure text you can use SecureField($password)

    https://developer.apple.com/documentation/swiftui/securefield

    If you want to set the contentType of an textField to eg. .oneTimeCode you can do it like this. Also works with keyboardType

    TextField($code)
        .textContentType(.oneTimeCode)
        .keyboardType(.numberPad)
    
    0 讨论(0)
提交回复
热议问题