Since the launch of iPhone 6s and 6s plus, Apple has introduced a new way of user interaction with mobile apps. A new dimension of touch event has been added by introducing 3D touch. By detecting how hard or deeply the user presses on the screen, you can do a specific action in your app. In the example below, we will see how to get the force of touch and log display on screen.
Using 3D touch
How to do it...
- As usual, open Xcode and create a new project with Single View template named 3D Touch.
- Open storyboard, and add a UILabel and place it at the center of the screen.
- Link the label with an IBOutlet to ViewController.swift.
- Go to ViewController.swift and override the following method:
override func touchesMoved(touches...