SwiftUI Shake Animation

Eduardo Domene Junior
Geek Culture
Published in
Oct 24, 2022
Photo by Guilherme Stecanella on Unsplash

Here is a quick sample of a shake animation done in SwiftUI with a completion block.

Use Case

The API is simple to use, you just need to call .shake() on any view while passing a State variable, and optionally a completion block that is executed once the animation is finished.

Implementation

The full code is the following:

--

--