From the course: Building Your First iOS 17 App
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Creating a slider in SwiftUI
From the course: Building Your First iOS 17 App
Creating a slider in SwiftUI
- [Instructor] One of the key parts missing from our tip calculator right now is a slider bar to adjust the tip percent. What we're going to do now is create that slider and have it go from values from one to 30. So let's take a look at how you'd create a slider in Swift UI. I'm going to go below the existing HStack here, so right after this curly brace on line 26, and I'm going to create a new HStack. So once I type a capital H, HStack is highlighted in the hinting, and I'll just press return, and then a space, an open curly brace, and then another return. Inside of this HStack, I'm going to create a slider. So I'm going to type the word slider and the one that we want here is value in and then we want one that says step after that. So I'm going to do value in step on editing changed. The reason, by the way, there are so many different values here, is because a slider can have various settings and you want to create…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.