From the course: Introducing App Development for iOS 14

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a TextField in SwiftUI

Creating a TextField in SwiftUI

From the course: Introducing App Development for iOS 14

Start my 1-month free trial

Creating a TextField in SwiftUI

- [Instructor] Now that we have our binding variable set up, we're able to create our text field and our slider. Let's start with the text field. So I've been referring to text fields throughout the course to reference this static text here that we set in our code. But in SwiftUI, there's a difference between text and text field. So text is non-editable text and a text field is a single line of editable text. So what I'm going to do is change text here to text field, and then open up the parenthesis, and you'll see a whole bunch of different values here. The one that we want is title with string protocol and text binding string. So choose that one. And here we need to give a title to our text field. So type some quotes, and we'll call this Total with a capital T, and then hit the Tab key this takes us over to binding string. So we need to put a string variable in here that is binding. And as I mentioned in a previous movie…

Contents