Reputation: 13675
I have a UIButton in my UIViewController in my storyboard, and I'm trying to change it's background image, using transition animation:
extension UIButton {
func setBackgroundImageWithFade(_ image: UIImage?,
duration: TimeInterval = 1.25,
completion : ((Bool) -> Void)? = nil) {
// Create a crossfade animation
UIView.transition(with: self, duration: duration, options: .transitionCrossDissolve, animations: {
self.setBackgroundImage(image, for: .normal)
}, completion: completion)
}
}
I've tried to change the button's type, and also the Background property is set to 'Custom'. but nothing works - the image won't change!
Upvotes: -1
Views: 51
Reputation: 13675
So this is the solution that worked for me:
on the button's attributes inspector panel I changed the Type -> Custom and also the Style -> Default.
Upvotes: 0