Can we change 3D touch short cut item icon?

835 views Asked by At

Here is my code.

    UIApplicationShortcutItem *bookmarksShortcutItem = [[UIApplicationShortcutItem alloc] initWithType:@"bookmarks" localizedTitle:@"Bookmarks" localizedSubtitle:@"test" icon:[UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeBookmark] userInfo:@{@"type":@"bookmarks"}];

So can I add my custom icon instead of UIApplicationShortcutIconTypeBookmark?

Thanks in advance.

2

There are 2 answers

2
Rajan Balana On BEST ANSWER

This is how you do it:

UIApplicationShortcutIcon *shortcutIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"IMAGE_NAME"];
UIMutableApplicationShortcutItem *option = [[UIMutableApplicationShortcutItem alloc] initWithType:@"uniqueIdentifier"
                                                                                   localizedTitle:@"title"
                                                                                localizedSubtitle:nil
                                                                                             icon:shortcutIcon
                                                                                         userInfo:nil];
[UIApplication sharedApplication].shortcutItems = @[option];
0
emmics On

Under UIApplicationShortcutItems you can specify your shortcuts, but you should do this in your plist rather than in the code. There you can create a dictionairy for every ShortcutAction and with UIApplicationShortcutItemIconFile you can define your own Icon.

This could be helpful for you:

http://www.the-nerd.be/2015/09/30/add-3d-touch-quick-actions-tutorial/