2015-09-28 159 views

回答

11

是有可能UIApplicationShortcutIcon。根據文檔:

有三種類型的快速動作圖標的:

  1. 從常見類型的系統提供的庫中的圖標,如在UIApplicationShortcutIconType枚舉

  2. 的描述從應用程序捆綁包中的自定義模板圖像派生的圖標,最好位於資產目錄中

  3. 表示用戶中的聯繫人的圖標的地址簿,您通過ContactsUI框架訪問(見ContactsUI框架 參考)

您可以使用iconWithTemplateImageName:到intialiaze新的按鈕。例如:

- (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; 
} 

參考Apple Docs.