iOS/코드조각

[iOS, Swift] UIView 애니메이션 효과

검은참깨두유vm 2022. 8. 21. 13:58
반응형

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.

 

let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.backgroundColor = .orange
self.view.addSubview(view)
UIView.animate(withDuration: 0.75, delay: 0.5, options: .curveEaseIn) {
    view.frame.origin.x = 200
    view.frame.origin.y = 200
} completion: { finished in
    view.backgroundColor = .blue
}

 

반응형