Junior — Middle
In which function do you initiate the execution of animation?
sobes.tech AI
Answer from AI
In iOS, animations are usually initiated inside the viewDidAppear(_:) function of a controller, because by this time all interface elements are loaded and displayed on the screen. This allows animations to start correctly when the screen appears. For example:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 0.5) {
self.myView.alpha = 1.0
}
}