Lecture 6: Animation

Stanford · 52K views · 2020 · 1:30:27

Open on YouTube

University lectures & coursesSoftware (other)lecturedated

Why Stack Overflow recommends it

Stack Overflow users link it in SwiftUI answers about animations, transitions and flip effects, as a thorough walkthrough of how withAnimation and animatable modifiers work.

Recommended by 2 people across 2 different months, 2020 to 2021.

What it is

Lecture 6 of Stanford's Spring 2020 iOS Application Development course (CS193p), covering SwiftUI animation. It explains implicit vs. explicit animations, transitions, animating Shapes and ViewModifiers, and applies them to the Memorize demo with card flips and bonus points.

What people said

Recommends YodagamaHeshan · 2020-12 · Stack Overflow · on “Transition is not working with ForEach nested in List with data from Core Data”

Since transition affect many view here. You have to do the changes related to transition inside withAnimation(Animation.easeIn) { //here you can change the animation you want //state changes should write here } This link may helpfull [this video]

Recommends Gry · 2021-08 · Stack Overflow · on “How to page down a Rectangle in SwiftUI?”

Hmm i feel you're missing the base of how swiftui works with views, and you patched some solutions from uikit to rotate things. I would suggest to watch some wwdc videos about swiftui or follow some base courses like the one that standford provide free on their youtube channel. Here a video that helps with your idea [this video] I added a solution that i come up on the fly but i would suggest to follow the Standford video because it provide a more complete solution where they use the AnimationModifier to handle the change from face up to flipped. To animate rotations you should use the .rotation3DEffect or .rotationEffect modifiers (it depends on the usecase). BTW here the base idea: flip to 90°

Cites i4guar · 2020-10 · Stack Overflow · on “How to stop SwiftUI DragGesture from animating subviews”

So this is my updated answer. I don't think there is a pretty way to do it so now I am doing it with a custom Button. import SwiftUI struct ContentView: View { @State var isShowing = false var body: some View { Text("Hello, world!") .padding() .onTapGesture(count: 1, perform: { withAnimation(.spring()) { self.isShowing.toggle() } }) .showModal(isShowing: self.$isShowing) } } extension View { func showModal(isShowing: Binding<Bool>) -> some View { ViewOverlay(isShowing: isShowing, presenting: { self }) } } struct ViewOverlay<Presenting>: View where Presenting: View { @Binding var isShowing: Bool let presenting: () -> Presenting @State var bottomState: CGFloat = 0 @State var isDragging = false