Book Image

Animating SwiftUI Applications

By : Stephen DeStefano
Book Image

Animating SwiftUI Applications

By: Stephen DeStefano

Overview of this book

Swift and SwiftUI are the backbone of Apple application development, making them a crucial skill set to learn. Animating SwiftUI Applications focuses on the creation of stunning animations, making you proficient in this declarative language and employing a minimal code approach. In this book, you'll start by exploring the fundamentals of SwiftUI and animation, before jumping into various projects that will cement these skills in practice. You will explore some simple projects, like animating circles, creating color spectrums with hueRotation, animating individual parts of an image, as well as combining multiple views together to produce dynamic creations. The book will then transition into more advanced animation projects that employ the GeometryReader, which helps align your animations across different devices, as well as creating word and color games. Finally, you will learn how to integrate the SpriteKit framework into our SwiftUI code to create scenes with wind, fire, rain, and or snow scene, along with adding physics, gravity, collisions, and particle emitters to your animations. By the end of this book, you’ll have created a number of different animation projects, and will have gained a deep understanding of SwiftUI that can be used for your own creations.
Table of Contents (18 chapters)

Animating a magic wand

In this project, we’re going to use the Magic particle system, and we will display that magic from the tip of a wand. You will be able to move the wand around the screen with your finger, and as it moves, magic will emanate from its tip. We will also have a cemetery background including a gravestone, and when you tap on the gravestone, a skeleton will rise up from it.

So, let’s get started with our spooky animation. Create a new project and call this one Magic. Next, add the resources for this project by dragging them from the Chapter 15 | Magic folder on GitHub into the Asset Catalog. Then, we can make our particle file.

Creating the magic SpriteKit particle file

As we’ve done before, create a new SpriteKit particle file, but select the Magic particle template, and simply call the file Magic. Now, let’s do something a little different this time – using the Texture field in the Attributes panel, select the star image...