Add pointer effect to custom alert actions

Closes #306
This commit is contained in:
Shadowfacts 2022-12-13 20:36:18 -05:00
parent 0c9f6e02bd
commit ba1eed7a85
1 changed files with 13 additions and 0 deletions

View File

@ -394,6 +394,8 @@ class CustomAlertActionButton: UIControl {
self.isContextMenuInteractionEnabled = true self.isContextMenuInteractionEnabled = true
self.showsMenuAsPrimaryAction = action.handler == nil self.showsMenuAsPrimaryAction = action.handler == nil
} }
addGestureRecognizer(UIHoverGestureRecognizer(target: self, action: #selector(hoverRecognized)))
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
@ -429,6 +431,17 @@ class CustomAlertActionButton: UIControl {
super.contextMenuInteraction(interaction, willEndFor: configuration, animator: animator) super.contextMenuInteraction(interaction, willEndFor: configuration, animator: animator)
} }
@objc func hoverRecognized(_ recognizer: UIHoverGestureRecognizer) {
switch recognizer.state {
case .began, .changed:
backgroundColor = .secondarySystemFill
case .ended:
backgroundColor = nil
default:
break
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)