【发布时间】:2018-05-16 11:22:36
【问题描述】:
我不断收到此错误:条件绑定的初始化程序必须具有可选类型,而不是“LOTAnimationView” 在 if let animationView = LOTAnimationView(name: "pop_heart") { 行代码上。我认为代码的格式可能是错误的。谁能指导我正确的方向?谢谢:)
override func viewDidLoad() {
super.viewDidLoad()
print("view loaded")
if let animationView = LOTAnimationView(name: "pop_heart") {
animationView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
animationView.center = self.view.center
animationView.contentMode = .scaleAspectFill
animationView.loopAnimation = true
animationView.animationSpeed = 0.5
view.addSubview(animationView)
animationView.play()
}}
【问题讨论】:
-
你的代码应该可以工作看看这个demo