An open API service indexing awesome lists of open source software.

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.

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);
}

```