2016-04-27 65 views
0

這是我的代碼。我們可以改變3D觸控捷徑項目圖標嗎?

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

那麼我可以添加自定義圖標而不是UIApplicationShortcutIconTypeBookmark嗎?

在此先感謝。

回答

3

這是你如何做到這一點:

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

感謝您的解決方案。我可以刪除所有的shortcutItem嗎?我有一個案例,當用戶登錄時,我應該顯示shortcutItem和沒有shortcutItem在沒有登錄的情況下。在此先感謝 –

+0

我可以改爲彩色自定義圖標嗎? –

相關問題