Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created December 7, 2018 18:12
Show Gist options
  • Save vialyx/74ca3a012a96624f6bd048b5967e1506 to your computer and use it in GitHub Desktop.
Save vialyx/74ca3a012a96624f6bd048b5967e1506 to your computer and use it in GitHub Desktop.
import UIKit
class AnimatableButton: UIButton, HighlightAnimatable {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
highlight(true)
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
highlight(false)
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
highlight(false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment