UIApplicationShortcutIcon

UIApplicationShortcutIcon

这是我的代码。

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

那么我可以添加我的自定义图标而不是UIApplicationShortcutIcon Type Bookmark吗?
提前致谢。

最佳答案

这是您的操作方式:

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

10-04 19:57