ForceTouchGestureRecognizerSwift 0.3

ForceTouchGestureRecognizerSwift 0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2015
SPMSupports SPM

Maintained by Ashley Mills.



  • By
  • Ashley Mills

ForceTouchGestureRecognizer.swift

UIGestureRecognizer Swift subclass enabling 3D Touch

Installation

Manual

Just drop the ForceTouchGestureRecognizer.swift file into your project. That’s it!

Example use

    override func viewDidLoad() {
        super.viewDidLoad()

        let forceTouchGesture = ForceTouchGestureRecognizer(target: self, action: "pressView:")
        forceTouchGesture.minimumValue = 0.1     // Minimum force value before touch is recognised 
        forceTouchGesture.tolerance = 0.2        // Allows the pressure to be lifted slightly without the gesture ending
        view.addGestureRecognizer(forceTouchGesture)
    }

    func pressView(gesture: ForceTouchGestureRecognizer) {
        print("force: \(gesture.forceValue)")  // forceVouch is CGFloat between 0 & 1
    }

Want to help?

Got a bug fix, or a new feature? Create a pull request and go for it!

Cheers, Ash