Creating a banner with a spring animation
A really nice and configurable easing function is the spring, where the component bounces around the final value.
We are going to implement a banner that is usually hidden, and when it appears, it moves from the top with a spring animation.
Getting ready
No external resources are needed, so let's just create a SwiftUI project in Xcode called BannerWithASpringAnimationApp
.
How to do it…
This is a really simple recipe, where we create a banner view that can be animated when we tap on a button:
- Let's implement
Banner
:struct Banner: View { let message: String var show: Bool var body: some View { Text(message) .font(.title) ...