How To Add 3D Touch To Your IOS App

3D Touch Utility

The 3D Touch innovation was first presented on the iPhone 6s and 6s+. Gadgets supporting 3D Touch are furnished with a tap drive delicate show, estimating the weight on the screen. The 3D Touch innovation enables clients to press an application symbol on the Home screen and get a fast access to some usefulness exhibited in the application. Additionally, inside an application, a client can access a few highlights.

From iOS 9, Apple influenced 3D To touch APIs accessible:

Home Screen Quick Action API

UIKit look and pop API

Web see look and pop API

UITouch compel properties

So as to see if a gadget underpins the 3D Touch innovation, you need to peruse out the forceTouchCapability esteems. While the application is working, a client can kill 3D Touch, so this esteem must be checked in the traitCollectionDidChange assign technique.

– (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {

on the off chance that (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {

NSLog(@”3D Touch is accessible”);

} else {

NSLog(@”3D Touch isn’t accessible on this gadget”);



3D Touch Quick Actions

There are two sorts of Home Screen Quick Actions: dynamic and static.

Static activities are characterized in the Info.plist document inside the UIApplicationShortcutItems cluster.

Dynamic activities must be added to the UIApplication application protest in the shortcutItems property. You can utilize two strategies for creation:

Strategy 1

init(type: String,

localizedTitle: String,

localizedSubtitle: String?,

symbol: UIApplicationShortcutIcon?,

userInfo: [AnyHashable: Any]? = nil)

This strategy makes a Home screen dynamic speedy activity with a header, discretionary subheader, discretionary symbol, and discretionary client information word reference.

Strategy 2

accommodation init(type: String,

localizedTitle: String)

Makes a Home screen dynamic fast activity with a header yet with no symbol.

Fast Actions Handler

func application(application: UIApplication,

performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool – > Void) {

let didHandle: Bool =/* handle the snappy activity utilizing shortcutItem */



func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) – > Bool {

var performAdditionalHandling = genuine

in the event that let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey]

as? UIApplicationShortcutItem {

/* handle the fast activity utilizing shortcutItem */

performAdditionalHandling = false


return performAdditionalHandling


UIKit look and pop API

This API is utilized for content see (speedy) and further change to it. New techniques in UIViewController for ViewController enrollment and enlistment cancelation permit warnings in the matter of whether it will be utilized by 3D Touch. Furthermore included are new conventions for 3D Touch bolster.

ViewController enlistment:

– (id)registerForPreviewingWithDelegate:(id)delegate sourceView:(UIView *)sourceView;


– (UIViewController *)previewingContext: (id)previewingContext viewControllerForLocation:(CGPoint)location {

/check in case we’re not as of now showing a see controller

in the event that ([self.presentedViewController isKindOfClass:[PreviewViewController class]]) {

return nil;


/shallow press: restore the see controller here (look)

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@”Main” bundle:nil];

UIViewController *previewController = [storyboard instantiateViewControllerWithIdentifier:@”PreviewView”];

return previewController;



– (void)previewingContext:(id)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {

/profound press: raise the confer see controller (pop)

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@”Main” bundle:nil];

UIViewController *commitController = [storyboard instantiateViewControllerWithIdentifier:@”CommitView”];

[self showViewController:commitController sender:self];

/on the other hand, utilize the view controller that is being given here (viewControllerToCommit)


In review, you can likewise include UIPreviewAction and UIPreviewActionGroup

UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@”Action 1″

style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull activity,

UIViewController * _Nonnull previewViewController) {

NSLog(@”Action 1 activated”);


/add them to an arrary

NSArray *actions = @[action1, action2, action3];

/add all activities to a gathering

UIPreviewActionGroup *group1 = [UIPreviewActionGroup actionGroupWithTitle:@”Action Group”

style:UIPreviewActionStyleDefault actions:actions];

NSArray *group = @[group1];

The True Potential of 3D Touch

As engineers are becoming acquainted with the advantages of the 3D innovation, it turns out to be certain that it will end up being a staple.

Along these lines, this commitment to opening the genuine capability of 3D Touch advancement in Shakuro.

Add a Comment

Your email address will not be published. Required fields are marked *