So I have a UIButton Extension
that allows all the buttons in my app to have a nice subtle animation. But recently I have thought of giving a few buttons a special animation but I am not sure how to give those few buttons a specific different animation other than the one that I have set universally for all the UIButtons
. Is there a way to override
this animation for just a few specific buttons?
Code for the extension of the button animation universally:
extension UIButton {
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
{
self.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 6, options: .allowUserInteraction, animations: {
self.transform = CGAffineTransform.identity
}, completion: nil)
super.touchesBegan(touches, with: event)
}
}