SwiftUI: Animation

Mar 29 2022 · Swift 5.5, iOS 15, Xcode 13

Part 1: Beginning with SwiftUI Animation

08. Interactive Animations

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 07. Multiple Stages Next episode: 9. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

At this point, you know plenty about creating animations with SwiftUI. But there is one last topic to cover: Creating beautiful animations driven by the user.

  @State var isVisible = true
  @State var currentOffset = CGSize.zero

  let shootUp =
        }
        .gesture(
          DragGesture()
        )
        .transition(shootUp)
          DragGesture()
            .onChanged { gesture in
              currentOffset = gesture.translation
            }
        )
  }

  func complete() {

  }
  
  func animate() {
      if iteration == 30 {
        timer.invalidate()
        complete()
      }
  func complete() {
    completed = true
    currentIndex = -1
    DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
      withAnimation {
        isVisible = false
      }
    }
  }
  func complete() {
    guard !completed else { return }

    completed = true
        .gesture(
          DragGesture()
            .onChanged { gesture in
              currentOffset = gesture.translation
            }
            .onEnded { gesture in
              if currentOffset.height > 150 {
                complete()
              }
            }
        )
                complete()
              }

              currentOffset = .zero
            }
        )
        .transition(shootUp)
        }
        🟩.offset(currentOffset)
        .gesture(
        .offset(currentOffset)
        🟩.blur(radius: currentOffset == .zero ? 0 : 10)
        .gesture(
        .blur(radius: currentOffset == .zero ? 0 : 10)
        🟩.animation(.easeInOut(duration: 1), value: currentOffset)
        .transition(shootUp)