Creating floating hearts in SwiftUI
When Periscope was introduced in 2015, it was the first app to popularize the live-streaming feature that is now a part of other apps, such as Facebook, Instagram, and YouTube.
A way of appreciating the streamer was to send a bunch of floating hearts, a feature that is now also implemented on Instagram and Facebook.
In this recipe, we'll see how to implement this feature in SwiftUI, as an example of a fairly complex real-world animation that can still be done easily.
Getting ready
Let's start by creating a SwiftUI app called FloatingHearts
.
For this recipe, we are going to use a third-party framework that provides a function to create an interpolation when given a small set of points.
The library is called SwiftCubicSpline
and can be found at https://github.com/gscalzo/SwiftCubicSpline; please refer to the Lottie Animations in SwiftUI recipe to see how to install an SPM
package using Xcode.
After downloading the framework...