Lottie๋ฅผ ์ฌ์ฉํด์ ์ ๋๋ฉ์ด์
์ ๋ฃ๊ธฐ
import UIKit
import Lottie
class MainViewController: UIViewController {
let titlelabel : UILabel = {
let label = UILabel()
label.textColor = .black
label.textAlignment = .center
label.text = "๋ฉ์ธํ๋ฉด"
label.font = UIFont.boldSystemFont(ofSize: 70)
return label
}()
let animationView : AnimationView = {
let animView = AnimationView(name:"95147-rocket")
animView.frame = CGRect(x:0, y:0, width: 400, height: 400)
animView.contentMode = .scaleAspectFill
return animView
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .black
view.addSubview(animationView)
animationView.center = view.center
animationView.play{(finish) in
print("์ ๋๋ฉ์ด์
์ด ๋๋ฌ๋ค")
self.view.backgroundColor = .white
self.animationView.removeFromSuperview()
self.view.addSubview(self.titlelabel)
self.titlelabel.translatesAutoresizingMaskIntoConstraints = false
self.titlelabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
self.titlelabel.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
}
}
}