Better Programming

Advice for programmers.

Follow publication

Member-only story

SwiftUI Advanced Animation: Morphing Shapes

Alex Dremov
Better Programming
Published in
4 min readMay 5, 2022

The regular .animate() function already provides a powerful way of animating views. Yet, its usage is limited to simple transformations.

In this guide, I'm going to show how complex SwiftUI views can be animated efficiently using VectorArithmetic protocol with Accelerate library for fast computations.

Inspiration

In the course of this guide, we will make a morphing sphere animation inspired by lava lamp bubbles. Some kind of wobbling lava bubbles.

💡 The proposed technique can be used in other even more complex animations

Wobbling bubble
Wobbling bubble

Creating custom animations

You may think about animation as a transition between two states. And this transition must be smooth! To display this smooth transition, SwiftUI needs to know how to draw in-between stages.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Write a response