43
GitHub - getaaron/HapticTouchGestureRecognizer: Haptic Touch gesture recognizer...
source link: https://github.com/getaaron/HapticTouchGestureRecognizer
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
HapticTouchGestureRecognizer
”iPhone Xʀ has a new feature we call Haptic Touch. So to get to the camera from the home screen, we just press on it. You feel a haptic tap, and you’re taken right to the camera.“
A gesture recognizer for iPhone Xʀ's Haptic Touch™ feature
- Works just like a
UILongPressGestureRecognizer
- Plays haptic feedback just like iPhone Xʀ's home screen
Installation
In your Podfile
:
pod 'HapticTouchGestureRecognizer'
Then run pod install
.
Usage
In your View Controller:
override func viewDidLoad() { super.viewDidLoad() let hapticTouchGestureRecognizer = HapticTouchGestureRecognizer(target: self, action: #selector(detected(gestureRecognizer:))) view.addGestureRecognizer(hapticTouchGestureRecognizer) } @objc func detected(gestureRecognizer: HapticTouchGestureRecognizer) { guard gestureRecognizer.state == .began else { return } // handle long press here // haptic feedback plays automatically }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK