April 2020
Beginner
316 pages
8h 20m
English
We'll again create a SwiftUI playground in order to test some of these examples out (see Chapter 13, Basic Animation in Views, on how we created a playground for use in SwiftUI).
We'll start by creating a simple button with a text view that will sit just beneath it:
VStack { Button("Basic Transitions") { // Add logic here... } Text("Learn SwiftUI")}
Nice and simple to start with, but our main intention here is to use transitions to bring in our text view when the button is clicked. Let's start by adding a @State variable and some conditional logic to make this happen:
@State var transition = false
Then we'll add the following highlighted changes:
Button("Basic Transitions") { self.transition.toggle()}if transition ...Read now
Unlock full access