Understanding timing curves
Animations have what are called curves. A curve, or more specifically, a timing curve, refers to the speed at which the animation starts and how it should end.
SwiftUI provides several timing curves to choose from that we can use inside the animation
modifier. It’s called a timing curve because if you were to plot each point of the animation’s movement from start to finish on a graph, and draw a line by connecting those points, most of them would create a curved line, as in this illustration:
Figure 2.1: The ease timing curves
This graph shows three animation timing curves: easeIn, easeOut, and easeInOut. The beginning of the animation is at the bottom left, and the end is at the top right. In the easeInOut
timing curve, the animation starts slow, speeds up, and then finally slows down before coming to a complete stop.
There is also a linear timing curve. An animation using this curve will have the same rate of speed at its beginning as it does at its end. If you were to plot it on a graph, it would be a straight line, like so:
Figure 2.2: The linear timing curve
Timing curves are not complicated – we get to choose the ones we want based on how we want the animation to look and perform. If you don’t specify a timing curve, you will get the default curve, the easeInOut
one. We will use some of these SwiftUI-provided timing curves in our projects.
In the next section, I want to explain the two distinct types of animation in SWiftUI: implicit and explicit.