Adding the variables
Our first task is to add some variables to keep track of the animations. There will be three animations, so in ContentView
, we need three boolean variables for them. We need to give them an initial value of false
, which will be changed to true
when the app first starts up:
struct ContentView: View { //animation bools @State var scaleUpDown = false @State var rotateInOut = false @State var moveInOut = false
The variables are called scaleUpDown
, rotateInOut
, and MoveInOut
. Usually, when you name your variables, you want to make them as descriptive as possible, so you don’t have to guess what they are used for and can recognize them right away, as we did here.
All the variables are now in place, so let’s move on to looking at the background of our animation.