반응형
Hacking with Swift 사이트의 강좌 번역본입니다.
[원문 : https://www.hackingwithswift.com/quick-start/swiftui/how-to-combine-transitions]
How to combine transitions
뷰를 추가하거나 제거할때, SwiftUI는 새로운 애니메이션 스타일을 만들기 위해 combined(with:) 메소드를 사용해서 전환(transitions)을 결합합니다. 예를들어, 다음과 같이 뷰를 이동(하나의 전환)하고 흐려지게(두번째 전환) 만들 수 있습니다.
Text("Details go here.")
.transition(AnyTransition.opacity.combined(with: .slide))
결합된 전환을 더 쉽게 사용하고 재사용 하기 위해, 다음과 같이 AnyTransition에서 확장을 만들 수 있습니다.
extension AnyTransition {
static var moveAndScale: AnyTransition {
AnyTransition.move(edge: .bottom).combined(with: .scale)
}
}
이를 통해서 텍스트 뷰를 추가하거나 제거할 수 있습니다.
Text("Details go here.")
.transition(.moveAndScale)
반응형
'SwiftUI > Animation' 카테고리의 다른 글
How to create a custom transition (0) | 2019.11.29 |
---|---|
How to create asymmetric 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 delay an animation (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 |