Created
August 7, 2020 12:32
-
-
Save hirauchg/8e64411e27cec94f98a3d05dedb28abb to your computer and use it in GitHub Desktop.
TextFieldの実装
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var name = "" | |
@State private var inputText = "" | |
var body: some View { | |
VStack { | |
TextField("名前を入力してください", text: $inputText, | |
onEditingChanged: { isBegin in | |
if isBegin { | |
// 入力開始時に行いたい処理を実装する | |
} else { | |
// 入力終了時に行いたい処理を実装する | |
} | |
}, | |
onCommit: { | |
// returnタップ時時に行いたい処理を実装する | |
self.name = self.inputText | |
}) | |
.font(.title) | |
.padding(20) | |
Text(name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment