
Animating SwiftUI Applications: Create visually stunning and engaging animations for iOS with SwiftUI
- Length: 478 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2023-03-13
- ISBN-10: 1803232668
- ISBN-13: 9781803232669
- Sales Rank: #1259758 (See Top 100 Books)
Unleash the power of SwiftUI by building dynamic, cross-platform projects that will amaze their users
Key Features:
- Explore the basics of declarative programming and animation
- Understand the fundamentals of SwiftUI and animatable properties
- Learn while working on beginner-to-advanced level animation projects
Book Description
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 at first, and then the book will transition into more advanced animation projects, incliuding building two complete game apps. Finally, you will learn how to integrate the SpriteKit framework into your SwiftUI code to create stunning scenes with smoke, wind, fire, rain, and snow scenes, by leverging and combining particle emitters into your SwiftUI 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 to develop your own unique creations.
What you will learn:
- Understand the fundamentals of SwiftUI and declarative programming
- Master animation concepts like State variables and timing curves
- Explore various animation properties like hueRotation, opacity, and scale
- Create animations using SpriteKit and Particle Emitters
- Use key coding techniques to manipulate and transform images, text, views, shapes, and more
- Work with SwiftUI controls like Buttons, Sliders, Pickers, and more
- Add audio to your animations for an interactive experience
Who This Book Is For
This book is for aspiring SwiftUI developers who have a basic understanding of Swift. It can also be used by SwiftUI developers, UIKit developers, and iOS developers that are new to SwiftUI and want to improve their animation proficiency.
Animating SwiftUI Applications Foreword Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Download a free PDF copy of this book Chapter 1: Exploring the Fundamentals of SwiftUI Technical requirements Understanding imperative and declarative programming Exploring the Xcode interface Understanding the state Understanding SwiftUI structures Computed properties Stacks Spacer views Divider views The padding modifier Closures GeometryReader Summary Chapter 2: Understanding Animation with SwiftUI Technical requirements What is animation? Understanding timing curves Understanding animation types Triggering animations Exploring animatable properties The offset property Hue rotation Opacity Scale Stroke, trim, and corner radius Summary Chapter 3: Creating a Breathing App Technical requirements Setting up the project with Xcode Adding the variables Implementing a background color Adding the circles Adding the first pair of circles Adding the second pair of circles Adding the third pair of circles Animating the circles Summary Chapter 4: Building a Record Player Technical requirements Adding images to the Assets catalog Creating the record player elements Creating the record player box Creating the spinning record Creating the record player arm Adding a custom dynamic button Creating a sound file to play audio Combining all the elements into one view Testing the project Summary Chapter 5: Animating Colorful Kaleidoscope Effects Technical requirements Adding the Binding variable and images Adding a Picker control and using a ForEach view Adding the variables and background color Adding the Image view and using the hueRotation modifier Summary Chapter 6: Animating a Girl on a Swing Technical requirements Gathering and slicing images Adding the animating variables Adding the images to the scene Adding the background Adding the right leg Adding the girl Adding the left leg Bringing the images together Using the mask modifier Summary Chapter 7: Building a Series of Belts and Gears Technical requirements Animating our first circular gear Animating a worm gear using shadows Using a marching ants effect to create a gear belt Animating a gear shaft image Animating a fan image Bringing everything together in ContentView Adding the motor Adding the gears along the x-, y-, and z-axes Adding the worm gear Adding the belts Adding the gear shafts Adding the fan Adding the background Summary Chapter 8: Animating a Bouquet of Flowers Technical requirements Adding the variables and a winter background Animating the text labels Using the blur modifier to create a vapor effect Animating flower petals in an arc Adding the flower bouquet and the animated breath Creating falling snow in the scene Adding the UIViewRepresentable protocol Dealing with methods and errors Adding the CAEmitter class Summary Chapter 9: Animating Strokes around Shapes Technical requirements Converting images into Swift code Removing the image backgrounds Vectorizing the images Translating the SVG file into Swift code Animating images with the stroke modifier Creating a stroke animation on the “WE” image Creating a stroke animation on the heart image Creating a stroke animation on the SwiftUI logo image Combining the animated strokes Summary Chapter 10: Creating an Ocean Scene Technical requirements Adding the wave’s offset property Creating a wave shape using the Shape protocol and Path function Adding the wave’s animatableData property Setting up the ContentView for animation Duplicating and animating the wave shape in the ContentView Adding an animated floating buoy to the ocean scene Making the buoy light blink Making the buoy move Adding the buoy to the scene Adding sound effects Summary Chapter 11: Animating an Elevator Technical requirements Setting up the project and adding a Binding variable Assembling the elevator using images and the GeometryReader view Putting people inside the elevator Creating a data model and using the ObservableObject protocol Adding the data model functions Adding the doorOpenTimer function Adding the playChimeSound function Adding the playDoorOpenCloseSound function Adding the floorNumbers function Adding the stopTimer function Adding the background, a button, and animating the doors Adding floor indicator lights Summary Chapter 12: Creating a Word Game (Part 1) Technical requirements Setting up the project and creating a data model Building out the UI by adding a text field and list Displaying a character count next to each word in the list Checking the entered words for duplicates Adding a random word with a button press Checking if the user’s entered word is possible Checking whether the user’s entered word is a real word Creating HeaderView with an info button Creating PickerView Adding PickerView Styling PickerView Summary Chapter 13: Creating a Word Game (Part 2) Technical requirements Creating a settings screen Adding the language buttons Adding a checkmark Adding a dismiss button Styling the UI Adding the background Adding animations to the game word Implementing user feedback with alerts Adding a Footer View to display more information Adding haptics and button sounds Summary Chapter 14: Creating a Color Game Technical requirements Understanding colors Creating the Title view Creating the target and guess circles Creating the Picker view Creating the target and guess rectangles Making the color sliders Keeping track of the user’s score with a button Showing the user’s score in an Alert view Resetting the game Adding a background Adding confetti using Swift packages Summary Chapter 15: Integrating SpriteKit into Your SwiftUI Projects Technical requirements Animating pipe smoke Creating a SpriteKit particle file Integrating the Smoke file into a SwiftUI View Animating coffee steam Creating the Smoke SpriteKit particle file Creating the Coffee Steam struct Filling out ContentView Animating rocket fire Adding FireView Adding RocketView Putting things together inside ContentView Animating a blizzard Creating two Snow SpriteKit particle files Creating a view that combines the two SKS files Animating the tree branches Animating rain Creating the Rain SpriteKit particle file Creating the raindrops Creating the puddle Putting it all together Animating a magic wand Creating the magic SpriteKit particle file Summary Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts Download a free PDF copy of this book
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Animating SwiftUI Applications: Create visually stunning and engaging animations for iOS with SwiftUI
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.