While developing iOS apps, developers are focusing on various technologies to deliver a richer user experience. 3D touch is one such technology introduced by Apple that completely transforms the mobile app development. 3D touch made its debut in the iPhone in September 2014 and it is accepted as a brilliant piece of screen technology. This feature is borrowed from Apple Watch, and it allows users to apply various levels of pressure on the iPhone’s touch screen.
What is 3D Touch?
3D touch is a newly added feature to the iPhone and is based on force touch technology. It gives the users a new set of gestures to deal with the apps' icons and details on the screen.
The idea behind 3D Touch is to sense the amount of pressure your finger applies to the screen and trigger various actions. 3D Touch enables soft press and hard press rather than the short press or long-press.
The 3D Touch has 3 levels of input based on pressure sensitivity. This technology is not available on all iPhones - iPhone XR does not support it for example. Here are the iPhone models that get 3D touch:
- iPhone 6s
- iPhone 6s Plus
- iPhone 7
- iPhone 7 Plus
- iPhone 8
- iPhone 8 Plus
- iPhone X
- iPhone XS
3D Touch’s Best Features on iPhone
- Quick Actions right away from Home Screen to access shortcuts
- Peek and Pop, preview content without having to open it
- Live photos, enable multitasking
Before moving deep into 3D features and implementation, it is important to ensure your device compatibility with 3D Touch. iOS developers use this code snippet to check 3D Touch availability in the given device:
Check 3D Compatibility
Home Screen Quick Action
This feature is available on the home screen and can be used to quickly access a certain part of the app to trigger an action. If you force touch an app icon; a menu will be presented. It enables you to quickly perform basic app-specific actions and find useful information. Camera, for example, provides a shortcut for taking a selfie, record video, take a photo, and record Sio-mo and as shown below:
The quick action is subdivided into static and dynamic actions.
Static Quick Action
The quick actions, which are specific to the app and it will never change are generated as static quick actions. These actions are developed at compile-time, and it will stay the same all the time. They will be available immediately on the device soon after the app installation even before its first launch. Here we defined four actions as static using the project’s Info.plist file:
Quick action entry in info.plist file
Here is the code snippet for defining static actions:
Quick Action handler in AppDelegate file
Static quick action in action
Dynamic Quick Action
Dynamic actions can be generated as well as deleted at run time. It reflects the user behavior, but it won’t appear until the code of these actions is run. To implement quick action, you need to create an instance of the UIApplicationShortcutItem object as shown below:
You can define any number of quick actions, but not more than four of them will be showed on the screen. In addition, static quick actions will be prioritized. So if you define two static actions and three dynamic actions, all of two static actions will be displayed followed by two of the dynamic quick actions.
Peek and Pop to Preview
Peek & Pop are pressure-sensitive gestures. If you press the app deeply, your interaction with the app proceeds through two phases:
- To peek, you need to press the device screen with a medium strength - Peek allows to preview the content of the app without opening it
- To Pop, you have to push it harder - Pop opens the item you pressed in the app
Some of the actions where Peek and Pop used for:
- Previewing images across applications
- Opening a location in Maps
- Viewing and opening web links
- Previewing and opening email content
To implement Peek and Pop, you need to add the UIViewControllerPreviewingDelegate function. The following code snippet integrates the 3D touch into the iOS application:
3D touch in UITableViewController
3DTouch in UICollectionViewController
As a result, if you touch the app Dog lists, a preview will be open up. It includes the list of Dogs on the selected breed as shown below:
When you press a little harder on any of the Dog images, it will pop up the full-screen image of the dog:
Peek and Pop example in action:
Examples that show the true potential of 3D touch on the iPhone:
- Drawing using 3D Touch - The harder you lift the thumb/finger, the line would be more darken.
- App Switcher – The left edge of the iPhone force touch can enable App Switcher rather than using double tap on the home button.
- Cursor positioning - Force touch on keyboard keystrokes allows moving cursor & selecting any word. This makes rewriting simple.
- Control Center - Control Center if you firmly press on the Wifi/Bluetooth section, more menus will open up including Airdrop & Hotspot.
- Flashlight - Press firmly on the Flashlight to set the intensity of brightness
- Folder - Press firmly on the folder to rename the folder. In addition, if any of the apps have notifications and that will also be notified.
Overall, we can say that the future of 3D touch is very bright as most enterprises hire iOS developers to unlock all its potential in their app. Enterprises saw the light and updating their apps to support this new way of access on the iPhone.