- withDuration : Animation의 지속시간
- animations : Animation 제공하는 클로저 표현식입니다.
//MARK: - animate(withDuration:animations:)
UIView.animate(withDuration: 0.5) {}
//MARK: - heading의 center x 값에 superView width값을 더해 Animation 처리
UIView.animate(withDuration: 0.5) {
self.heading.center.x += self.view.bounds.width
}
- withDuration : Animation의 지속시간
- delay : UIKit이 Animation을 시작하기 전에 대기하는 시간(초)입니다.
- options :Animation에 대한 여러 측면을 사용자 지정할 수 있습니다.
- completion : Animation이 완료될 때 실행할 코드 클로저입니다.
//MARK: - animate(withDuration: , delay: , options: , animations:, completion:)
UIView.animate(withDuration: , delay: , options: , animations:, completion:)
//MARK: - Animation의 지속시간을 0.5초로 설정하며, 딜레이를 0.5초를 주웠으며, cloud1의 alpha값을 1.0을주며 Animation 처리
UIView.animate(withDuration: 0.5, delay: 0.5, options: [], animations: {
self.cloud1.alpha = 1.0
}, completion: nil)
//MARK: - 위 작업과 동일하게 Animation의 지속시간은 동일하나 딜레이를 0.7초로 설정하여 위의 Animation보다 0.2초후에 실행됨
UIView.animate(withDuration: 0.5, delay: 0.7, options: [], animations: {
self.cloud2.alpha = 1.0
}, completion: nil)
- withDuration : Animation의 지속 시간
- delay : UIKit이 Animation을 시작하기 전에 대기하는 시간(초)입니다.
- usingSpringWithDamping : Spring Animation이 정지 상태(= Animation이 끝나갈 때)에 근접할 때의 damping(감쇠)비율을 말한다. 0.0 ~ 1.0 까지의 값을 가지고 있으며, 0에 가까울수록 심하게 damping이 됩니다.
- initialSpringVelocity : Animation을 시작할때 View의 상대적 속도 0.0 ~ 1.0 까지의 값을 가지고 있으며, 0에 가까울수록 더 빨라진다.
- options : Animation에 대한 여러 측면을 사용자 지정할 수 있습니다.
- animations : Animation 제공하는 클로저 표현식입니다.
- completion : Animation이 완료될 때 실행할 코드 클로저입니다.
//MARK: - animate(withDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)
UIView.animate(withDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)
//MARK - Example
UIView.animate(withDuration: 0.5, delay: 0.5, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.0,
options: [], animations: {
self.loginButton.center.y -= 30.0
self.loginButton.alpha = 1.0
}, completion: nil)