목록SwiftUI - 기초 (55)
기어가더라도 제대로

animation도 background, padding, 과 마찬가지로 some View 를 반환한다. 여기서 도출되는 결론이 두가지 있다. 애니메이션을 적용하는 순서가 중요하다. 여러개의 애니메이션을 중첩해서 사용할 수 있다. 위의 두 가지 결론을 쫒아가보는 포스팅이 될 것이다. View 적인 특성에 대해서 알고 싶으시다면 다음 포스팅을 참조하시라. 2022.10.14 - [Swift - 기초] - [SwiftUI-기초] Modifier 적용 순서가 중요한 이유 애니메이션의 적용 순서가 중요한 이유 결론부터 말하자면, .animation() modifier 앞에 적용된 modifier들만 애니메이션 처리가 된다. .animation 뒤로 적용된 modifier의 경우에는 애니메이션 처리가 되지 않는다...

withAnimation { } 도 물론 있지만, 숨겨져 있는 Animation modifier 들을 알아보자. Button에 붙이는 애니메이션 빨간색 원을 만들고 버튼을 누를 때마다 크기가 늘어나도록 설정을 해봄 . scaleEffect() : 이 모디파이어를 사용해서 버튼의 크기를 조절할 것임 struct ContentView: View { @State private var animationAmount = 1.0 var body: some View { Button("Tap Me") { animationAmount += 1 } .padding(50) .background(.red) .foregroundColor(.white) .clipShape(Circle()) .scaleEffect(animation..

UIKit 에선 viewDidLoad, viewWillAppear 등 뷰 생명주기에 관한 메소드가 있었음 근데 SwiftUI 에선 그런게 없을까? 하던 차에 발견을 해서 정리를 함 .onAppear(perform: ) 위의 modifier 를 뷰 아무곳에나 달면 뷰가 처음 시작할 때 perform 안에 메서드를 한번 실행함 클로저 형태로 달 수도 있음 뷰가 사라질때 실행하는 모디파이어 .onDisappear { }