SwiftUI Animations by Tutorials by By Bill Morefield & By Irina Galata

SwiftUI Animations by Tutorials by By Bill Morefield & By Irina Galata

Author:By Bill Morefield & By Irina Galata
Language: eng
Format: epub
Publisher: Kodeco Inc


You’re so close to the finish line with only a few things left to polish.

Final Animating Touches

Since a seat is essentially a Path, just like a tribune, it’s pretty easy to animate it by trimming it. Add a new property of type CGFloat to SeatingChartView:

@State private var seatsPercentage: CGFloat = .zero

Find seat.path and trim the seat’s stroke and fill:

seat.path .trim(from: 0, to: seatsPercentage) .fill(selectedSeats.contains(seat) ? .green : .blue) seat.path .trim(from: 0, to: seatsPercentage) .stroke(.black, lineWidth: 0.05)

Go back to findAndSelectTribune and add the following line below anchor:

seatsPercentage = selectedTribune == nil || !unselected ? 0.0 : 1.0

Now, the animation will reset every time you select a new tribune.

Additionally, update seatsPercentage in the first of the two linked animations, right below zoom:

seatsPercentage = unselected ? 0.0 : 1.0

Check it out:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.