I have made my own custom UIView which displays a label in the top left of the UIView, along with some borders.
Inside the custom UIView (AdventDoor), I have created a method called animateChanges(). This is what's inside the method:
func animateChanges()
{
UIView.animate(withDuration: 1.5, animations: {
self.layer.backgroundColor = UIColor.white.cgColor
})
}
The initial colour of this view is UIColor.red, what I want is for the background colour to fade to white within 1.5 seconds, however, the background jumps to white instantly without the animation.
This is what is inside my draw method:
override func draw(_ rect: CGRect) {
if(self.tag < 25)
{
doorNumber.text = "\(self.tag)"
} else {
doorNumber.text = "25"
}
self.addSubview(doorNumber)
}
How would I make the views background colour fade from red to white? I have also tried changing UIView.animate to AdventDoor.animate
I also added the code self.backgroundColor = UIColor.clear
before the UIView.animation
code and for some reason, the animation works. The only problem is, I want it to fade from red to white instead of clear to white.