forked from shadowfacts/Tusker
Add pointer interaction to ToastView
This commit is contained in:
parent
4dca231a06
commit
91b7ce3008
|
@ -53,6 +53,8 @@ class ToastView: UIView {
|
||||||
layer.shadowOpacity = 0.5
|
layer.shadowOpacity = 0.5
|
||||||
layer.masksToBounds = false
|
layer.masksToBounds = false
|
||||||
|
|
||||||
|
addInteraction(UIPointerInteraction(delegate: self))
|
||||||
|
|
||||||
let stack = UIStackView()
|
let stack = UIStackView()
|
||||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||||
stack.axis = .horizontal
|
stack.axis = .horizontal
|
||||||
|
@ -282,3 +284,21 @@ extension ToastView: UIGestureRecognizerDelegate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ToastView: UIPointerInteractionDelegate {
|
||||||
|
func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? {
|
||||||
|
return defaultRegion
|
||||||
|
}
|
||||||
|
|
||||||
|
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
||||||
|
return UIPointerStyle(effect: .highlight(UITargetedPreview(view: self)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||||
|
shouldDismissAutomatically = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||||
|
shouldDismissAutomatically = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue