我正在尝试在图像视图上执行缩放动画。完成后,我将图像更改为红色版本。但是在这之间它显示了一种奇怪的蓝色,我不想显示。这是我用于动画的代码。谢谢
self.likeAnimateView.image = self.likeAnimateView.image!.withRenderingMode(UIImageRenderingMode.alwaysTemplate)
UIView.animate(withDuration: 0.182,
animations: {
self.likeAnimateView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
},
completion: { _ in
UIView.animate(withDuration: 0.182) {
self.likeAnimateView.transform = CGAffineTransform.identity
self.likeAnimateView.image = UIImage(named: "heartsel") // Red image
}
})
答案 0 :(得分:0)
根据@Karthikeyan Bose的建议。我在动画之前添加了这一行代码。
self.likeAnimateView.image = UIImage(named: "heart")//Deafault color before the animation to get rid of the blue color
UIView.animate(withDuration: 0.182,
animations: {
self.likeAnimateView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
},
completion: { _ in
UIView.animate(withDuration: 0.182) {
self.likeAnimateView.transform = CGAffineTransform.identity
self.likeAnimateView.image = UIImage(named: "heartsel") // Red image
}
})