Member-only story

New SwiftUI: Lava Animation with Canvas & DragGesture.

AnthonyDesignCode
4 min readSep 22, 2022

--

Photo by Martin Engel on Unsplash

Hello everyone, welcome to a new SwiftUI tutorial. I hope you are all doing well. Today I am going to show you how to create a Lava Animation with Canvas & DragGesture in SwiftUI 4 and Xcode 14.

Let’s get started with opening up Xcode 14. We are going to code this in the ContentVie, but first we are going to add our two colour to the assets file

Assets

Over in the ContentView we are going to build out the main ui without the Animations first.

ContentView

Now we are going to build the Circle Animation and get this a run to see what we get! 🔥 We are going to be using a ViewBuilder here.

What is a Canvas in SwiftUI?

A view type that supports immediate mode drawing. Use a canvas to draw rich and dynamic 2D graphics inside a SwiftUI view. The canvas passes a GraphicsContext to the closure that you use to perform immediate mode drawing operations.

How to use a DragGesture in SwiftUI?

--

--

AnthonyDesignCode
AnthonyDesignCode

Written by AnthonyDesignCode

Hey 👋 I’m Anthony! I hope you are well?! Thank you for looking at my blog. Here you will learn how to make apps in SwiftUI for iOS 16! Thanks for reading.

No responses yet