iOS9 3DTouch Tutorial: Introduction
- With iOS 9, new iPhone models add a third dimension to the user interface: 3DTouch.
- A user can now press your app's Home screen icon to immediately access functionality provided by your app. (Ex: Open Chats page, Profile Page, or a Notification page in your Social App)
- Within your app, a user can now press views to see previews of additional content and gain accelerated access to features. (Ex: Force on a
UICollectoinViewCellto see details of any post in your Social App)
The Current API allows you to use three behaviours to make your app 3DTouch-enabled.
- Home Screen Quick Actions
- Peek and Pop
1. Home Screen Quick Actions
By pressing an app icon from your 3DTouch-enabled device, the user will obtain a set of quick actions. When the user selects a quick action, your app activates or launches, and your app delegate object receives the quick action message.
There are two types of quick actions:
- Static Quick Actions:
Define static quick actions in your app’s
Info.plistfile in the
UIApplicationShortcutItemscan include Icon, Title, Subtitle,Type, and extra user info to show and use on
- Dynamic Quick Actions: You can add dynamic quick actions with the
UIApplicationShortcutItemclass and its associated APIs. You can also add your dynamic quick actions to your app’s shared
UIApplicationobject using the new
- Both types of quick actions can display up to two lines of text along with an optional icon.
- You can add a maximum of 4 quick actions to your app
2. Peek and Pop
You can now enable the view controllers in your app (instances of the
UIViewController class) to respond to user presses of various intensities. As the user presses more deeply, interaction proceeds through three phases:
Peek: Indication that content preview is available,
and display of the preview known as a peek (with options to act on it directly known as peek quick actions)
Pop: Optional navigation to the view shown in the preview known as a pop.
In iOS 9, the
UITouch class has two new properties to support custom implementation of 3D Touch in your app: force and maximumPossibleForce.
For the first time on iOS devices, these properties let you detect and respond to touch pressure in the
UIEvent objects your app receives.
Note: The force of a touch has a high dynamic range, available as a floating point value to your app.
Download samples provided by Apple
Stay tuned for next 3DTouch practicals as well.