From the course: iOS 14 Development Essential Training

Unlock the full course today

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

Increasing reusability in custom views

Increasing reusability in custom views

From the course: iOS 14 Development Essential Training

Start my 1-month free trial

Increasing reusability in custom views

- [Instructor] Let's say for our ColorSliderView, we also want it to be able to change the color swatch from here in our content view. This will allow us to create blue and green sliders with one line of code each. Let's head over to our ColorSliderView, so I'm hovering over the left side of my screen and full screen, where we can show the navigator view here, So I'm going to ColorSliderView, and I want you to take a minute to think about what it would take to allow us to do what we want. Now, if you're new to programming it might be a difficult puzzle to solve. What we need to do is create another variable so that whenever we create a ColorSliderView, we need to send in this value as well. So below binding var, type var, color, colon the data type for this is going to be a color. Remember, we did the exact same thing in our color swatch and we don't need to use the @Binding or at state color. Now, if you want to, you…

Contents