Custom UIApplicationShortcutIcon

Is it possible to create a UIApplicationShortcutIcon user interface? Or just the one that gave the apple?

enter image description here

+6
source share
1 answer

Yes, it is possible for UIApplicationShortcutIcon. According to the docs:

There are three types of quick action:

  • Icon from the system-provided generic type library, as described in the UIApplicationShortcutIconType enumeration

  • An icon obtained from a custom template in your application package and preferably in the asset catalog

  • An icon representing a contact in the user's address book, which is accessed through the ContactsUI structure (see Link)

You can use iconWithTemplateImageName: to create a new button. For instance:

 - (void)createDynamicShortcutItems { // create several (dynamic) shortcut items UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 1" localizedTitle:@"Item 1"]; UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 2" localizedTitle:@"Item 2"]; UIApplicationShortcutItem *item3 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 3" localizedTitle:@"Item 3"]; // add all items to an array NSArray *items = @[item1, item2, item3]; // add the array to our app [UIApplication sharedApplication].shortcutItems = items; } 

Refer to Apple Docs .

+11
source

All Articles