0

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.

James Webster
  • 31,873
  • 11
  • 70
  • 114
Ajith Kumar
  • 1,202
  • 1
  • 10
  • 22

2 Answers2

4

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];
Rajan Balana
  • 3,775
  • 25
  • 42
  • Thanks for the solution. Can I remove all the shortcutItem? I have a case, When user logged in I should show shortcutItem and no shortcutItem in case of no login. Thanks in Advance – Ajith Kumar Apr 28 '16 at 06:10
  • Can I put a colored customize icon instead? – wes. i Jan 31 '18 at 10:55
0

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/

emmics
  • 994
  • 1
  • 11
  • 29