Search

변경자의 순서도 애니메이션에 영향을 받는다.

부제
카테고리
SwiftUI
세부 카테고리
애니메이션
Combine 카테고리
최종편집일
2022/07/16 15:58
작성중
관련된 포스팅
생성 일시
2022/07/16 15:58
태그
struct Study_lecture20: View { @State var show = false var body: some View { ZStack{ Color.blue.ignoresSafeArea() .opacity(show ? 0.5 : 0.2) .animation(.linear(duration: 0.8)) RoundedRectangle(cornerRadius: 40) .foregroundColor(.white) .frame(height: 300) .padding(show ? 16 : 32) .offset(y: show ? 0 : 30) //여기까지는 spring 애니메이션 적용됨 .animation(.spring(response: 0.6, dampingFraction: 0.01)) .opacity(show ? 1 : 0.5) //위 오패시티는 리니어 애니메이션 적용됨. .animation(.linear(duration: 0.5)) //response : 무게감 / dampingFraction : 유연성 } .onTapGesture { show.toggle() } } }
Swift
복사