Instance Method インスタンスメソッド

keyboardType(_:)

Sets the keyboard type for this view. キーボード型をこのビューに対して設定します。

Declaration 宣言

func keyboardType(_ type: UIKeyboardType) -> some View

Parameters パラメータ

type

One of the keyboard types defined in the UIKeyboardType enumeration.

Discussion 議論

Use keyboardType(_:) to specify the keyboard type to use for text entry. A number of different keyboard types are available to meet specialized input needs, such as entering email addresses or phone numbers.

The example below presents a TextField to input an email address. Setting the text field’s keyboard type to .emailAddress ensures the user can only enter correctly formatted email addresses.


TextField("someone@example.com", text: $emailAddress)
    .keyboardType(.emailAddress)

There are several different kinds of specialized keyboard types available though the UIKeyboardType enumeration. To specify the default system keyboard type, use .default.

A screenshot showing the use of a specialized keyboard type with a