April 2020
Intermediate to advanced
528 pages
15h 40m
English
Let’s add one final animation touch to the application. When the current mood is changed, also animate the add mood button’s background color. You will use the same property animator technique that you used above.
Modify the property observer for currentMood to animate the button’s background color.
Listing 19.9 Animating the button’s background color (MoodSelectionViewController.swift)
var currentMood: Mood? {
didSet {
guard let currentMood = currentMood else {
addMoodButton?.setTitle(nil, for: .normal)
addMoodButton?.backgroundColor = nil
return
}
addMoodButton?.setTitle("I'm \(currentMood.name)", for: .normal)
addMoodButton?.backgroundColor = currentMood.color
let selectionAnimator = UIViewPropertyAnimator(duration: ...Read now
Unlock full access