目标
我需要我的应用来缩放 UIImage
。
代码
为此,我使用以下方法:
func animateStuff() {
println("Animate stuff called!")
let optionsAnimateStuff = UIViewAnimationOptions.Repeat | UIViewAnimationOptions.Autoreverse | UIViewAnimationOptions.AllowUserInteraction
let value : CGFloat = 1.045
UIView.animateWithDuration(0.9, delay: 0.0, options:
optionsAnimateStuff, animations: {
println("Let's scale this image!")
self.image.transform = CGAffineTransformMakeScale(value, value)
}, completion: { finished in })
}
当我关闭应用程序并再次打开它时,该方法会再次被调用(由于 applicationDidBecomeActive
中的代码,但 UIImage
不再动画。
问题
为什么对象没有动画?
最佳答案
问题可能是图像仍然应用了之前的变换。您可能希望在动画完成时(当 View 消失时)将其返回到原始状态。
尝试在完成
中使用此代码:
{ finished in
self.image.transform = CGAffineTransformIdentity
}
关于重新打开应用程序后动画未开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28225152/