Home SwiftUI animation
SwiftUI animation, on the phone
SwiftUI animation here means one component that keeps time. You write the file on your iPhone, press play, and the phone runs it. Then you copy the same source into Xcode.
A sketch of the motion. The file below plays on the phone, and the same source pastes into Xcode.
Two ways a component keeps time
A TimelineView reads the clock. Every frame gets a new date, and you turn that date into an offset, a scale, or an angle. A loader keeps spinning after the state has stopped changing, because the clock has not.
withAnimation is the other one. You change an @State value inside it, and SwiftUI interpolates the views that read that value. A tap, a spring, and it settles. It does not spin forever. The timeline does.
A file
import SwiftUI struct PulseDot: View { var body: some View { TimelineView(.animation) { context in let t = context.date.timeIntervalSinceReferenceDate let wave = sin(t * .pi * 2 / 1.2) let scale = 0.85 + 0.15 * (wave + 1) / 2 Circle() .fill(.orange) .frame(width: 48, height: 48) .scaleEffect(scale) } } }
That is the whole component. sin turns the date into a scale between 0.85 and 1, and the circle breathes. The same source plays in Swoop and pastes into an Xcode project for iOS 17 or later. Nothing to import beyond SwiftUI.
The richer loader on the home page is the same idea with two dots and a little depth. The pages below each take one motion and leave you the file.
The set
- SwiftUI loading animationTwo dots on a timeline.
- SwiftUI rotation animationAn angle, every frame.
- withAnimationChange state, and the view eases.
- SwiftUI onAppear animationMove once, when the view shows up.
- SwiftUI offset animationPlace a shape without a stack doing it.
- SwiftUI code previewThe stage runs the file. It does not mime it.
- Learn SwiftUIOne view at a time. Not a course.
What this is not
Swoop is one component, postcard size. It is not a screen, and it will not pretend to be one. A container meant for a whole app is refused, and the message names the line, because a guess that would not compile in Xcode is worse than a stop.
It is also not a course, a book, or a pack of templates. If you want a class, this is the wrong site. If you want a file you can run today, open any page in the set. Learn SwiftUI is the short version of how to start. SwiftUI code preview is what the stage actually does.
Questions
Does the animation run in the browser?
No. The sketch on each page is a drawing of the motion. The Swift file plays in Swoop, on your iPhone.
Will the file compile in Xcode?
Yes. It is plain SwiftUI. Paste it into a project that targets iOS 17 or later. There is nothing else to import.
Is this a course?
No. Each page is one component. Swoop is not a class, a book, or a place to build a whole app.
iPhone. iOS 17 and later. The file plays on the phone.