【发布时间】:2017-03-10 03:34:00
【问题描述】:
我是 iOS Swift 开发的新手,我尝试在一个动画中组合三个参数,但我没有成功。
我认为解决方案在这里 -Apple Dev Core Animation Programming Guide 通过对动画进行分组,但作为初学者,经过大量互联网研究后,我找不到我想要的东西。
您如何看待我的代码,以及对您而言,结合性能和稳定性的最佳解决方案是什么。
我想指出,这个动画的目的是创建一个动画的 Splashscreen。还有其他元素(UIImage)将用于动画。
这是我的代码:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
logoImg.alpha = 0
logoImg.transform = CGAffineTransform(translationX: 0, y: -200)
logoImg.transform = CGAffineTransform(scaleX: 0, y: 0)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 1.0, delay: 1.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10, options: [.curveEaseOut], animations: {
self.logoImg.transform = CGAffineTransform(translationX: 0, y: 0)
self.logoImg.transform = CGAffineTransform(scaleX: 1, y: 1)
self.logoImg.alpha = 1
}, completion: nil)
}
【问题讨论】:
-
变换不能是两个不同的变换。你只是用另一个替换一个。你肯定是想把它们结合起来。
标签: ios iphone animation swift3 cgaffinetransform