https://github.com/imanx/force-touch-recognizer
Simple classes for handle of 3D Touch & Force Touch on Swift.
https://github.com/imanx/force-touch-recognizer
3dtouch forcetouch ios recognizer swift
Last synced: 10 months ago
JSON representation
Simple classes for handle of 3D Touch & Force Touch on Swift.
- Host: GitHub
- URL: https://github.com/imanx/force-touch-recognizer
- Owner: ImanX
- Created: 2019-03-09T12:07:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T07:42:00.000Z (about 7 years ago)
- Last Synced: 2025-04-14T01:49:03.573Z (about 1 year ago)
- Topics: 3dtouch, forcetouch, ios, recognizer, swift
- Language: Swift
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# force-touch-recognizer
Simple classes for handle of 3D Touch & Force Touch in Swift.
Simply handle force touch on your swift project bassed `UIGestureRecognizer`
```swift
override func viewDidLoad() {
super.viewDidLoad()
let forceGesture = UIForceTouchGestureRecognizer(target: self, action: #selector(didForce),force: 6.0)
forceGesture.forceDelegate = self; //if you implemented protocol.
forceGesture.isEnableNotifyFeedback = true; //if you will feedback.
view.addGestureRecognizer(forceGesture)
}
//this method of UIForceTouchRecognizerDelegate and optional.
func didRecognizer(force: CGFloat) {
print(force)
}
//When touch forced invoke this .
@objc func didForce() {
let alert = UIAlertController(title: "3D Touch", message: "3D touch worked succesfully", preferredStyle: .actionSheet);
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil));
UIApplication.shared.windows.first?.rootViewController?.present(alert, animated: true, completion: nil);
}
```