2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TextFieldにてアルファベット入力時に先頭文字が大文字になってしまうことを防ぐ

Posted at

問題

TextFieldを用いた画面を作成した際に入力時に先頭文字が自動的に大文字になってしまうことがある。
特に、Canvasを使用して画面の動作を確認する際に、キーボードからの入力だと、大文字を小文字に変換する術がなく、辛い。
ezgif.com-gif-maker.gif

解決方法

TextFieldのModifiersである、autocapitalization(_:)を使用して、大文字への自動変換を制御すれば良い。

TextField("ユーザー名", text: $vm.userName)
    .autocapitalization(.none)
TextField("メールアドレス", text: $vm.emailAddress)
    .autocapitalization(.none)

ezgif.com-gif-maker (1).gif

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?