Swift 变色显示不同的颜色

Swift color change shows different color

我正在尝试在图像视图上制作比例动画。完成后,我将图像更改为红色版本。但是在 之间它显示了一种我不想显示的奇怪的蓝色 。这是我用于动画的代码。谢谢

 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
                            }
                        })

根据@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
                   }
               })