반응형
Hacking with Swift 사이트의 강좌 번역본입니다.
[원문 : https://www.hackingwithswift.com/quick-start/swiftui/how-to-delay-an-animation]
How to delay an animation
모든 애니메이션(암시적, 명시적, 바인딩)을 만들때 애니메이션 동작 방법을 조정하는 modifiers를 붙일 수 있습니다. 예를들어, 몇 초 후에 애니메이션을 시작하기 원하는 경우에는 delay() modifier를 사용해야 합니다.
예를들어, 다음은 탭할때 빨간 사각형을 만들고, 1초 지연(delay)하고 2초동안 애니메이션을 사용해서 360도 회전할 것입니다.
struct ContentView: View {
@State var rotation = 0.0
var body: some View {
Rectangle()
.fill(Color.red)
.frame(width: 200, height: 200)
.rotationEffect(.degrees(rotation))
.animation(Animation.easeInOut(duration: 3).delay(1))
.onTapGesture {
self.rotation += 360
}
}
}
반응형
'SwiftUI > Animation' 카테고리의 다른 글
How to create asymmetric transitions (0) | 2019.11.29 |
---|---|
How to combine transitions (0) | 2019.11.29 |
How to add and remove views with a transition (0) | 2019.11.29 |
How to apply multiple animations to a view (0) | 2019.11.29 |
How to start an animation immediately after a view appears (0) | 2019.11.29 |
How to create an explicit animation (0) | 2019.11.28 |
How to animate changes in binding values (0) | 2019.11.28 |
How to create basic animations (0) | 2019.11.28 |