An experimental project for 3D Touch on new iPhones.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ForceTouch
.gitignore
LICENSE
README.md

README.md

USSForceGestureRecognizer

USSForceGestureRecognizer is an experimental force gesture recognizer for iOS. It is written in Swift 2.0 and supports iOS 9 and onwards. The purpose of this project is to test out developer APIs for 3D Touch (previously Force Touch, which is still referenced in the APIs) and provide a convenience API with UIGestureRecognizer pattern, instead of UITouch.

Because we currently cannot use 3D Touch APIs in the simulator, we are patiently waiting for iPhone 6s to be released, so we can test them.

The recognizer is implemented in USSForceGestureRecognizer class. It has a property touchType to differentiate between both levels of 3D Touch - Deep and Shallow.

Installation

The easiest way to install USSForceGestureRecognizer is to drag & drop USSForceGestureRecognizer.swift file in your project.

Usage

USSForceGestureRecognizer is easily added to an UIView, just like a normal UIGestureRecognizer.

let recognizer = USSForceGestureRecognizer(target: self, action: "forceTouchDeepRecognized:")
recognizer.touchType = .Deep

view.addGestureRecognizer(recognizer)

To support all 3 types of finger interaction on specific UIView, three recognizers have to be added:

  • UITapGestureRecognizer
  • USSForceGestureRecognizer - With touchType property set to .Shallow (default).
  • USSForceGestureRecognizer - With touchType property set to .Deep.

Disclaimer

The project will be updated once we can test this on a physical device. It only supports force taps for now, but if it turns out it would be possible to add force swipe and pan recognizers, we will update the project later.

Contact

Dal Rupnik

License

USSForceGestureRecognizer is released under the MIT license. See LICENSE file for more information.