From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Updating UIViewControllers

Updating UIViewControllers

- [Instructor] With the view controller installed, often that's all you'll need to do, but there may be interaction with the Swift UI code, for example, we might want the view controller to change when we press the circle button. So let's set that up next. So let's go back into Aloha Pizza View here. And we're going to set up a binding variable of type bool. We'll call it button state. Update UI view controller, it's going to use this to change the code in our view controller. Well, you don't have to do this step, I find it helps in coding. This UI view controller here is the view controller. Just to make it easier to work with, I often copy that and just make vc = uiViewController. I'm going to go over to Aloha view controller and the code for the button here. And that's up here if you look here. Okay, so here's our IB action but now I'm going to copy the if else in here. That says the text for the labels on button title.…

Contents