Animating view colour changes
Published on · Updated on
1 minute read
When animating the addition of cells to a UICollectionView
, we may notice that text and background colours aren't animating when using UIView.animate
. Using UIView.transition
instead works perfectly!
UIView.transition(with: commentContainer, duration: 0.6,
options: .transitionCrossDissolve, animations: {
commentContainer.backgroundColor = UIColor(red: 17, green: 215, blue: 198)
})
UIView.transition(with: commentLabel, duration: 0.6,
options: .transitionCrossDissolve, animations: {
commentLabel.textColor = UIColor(red: 143, green: 155, blue: 174)
})
I hope the article was useful. If you have any feedback or questions please feel free to reach out to me on Twitter.
Thanks for reading and happy coding!
Hi, I hope you enjoyed the article. I am Andrew - a builder of apps and developer tools. Articles on the blog focus on all aspects of Android and iOS development using Kotlin and Swift.