如何爲UIApplicationShortcutItem
添加自定義圖像UIApplicationShortcutIcon
?類似於照片UIApplicationShortcutItem
在照片/消息應用程序中爲最近。由於所有圖標都是從一個自定義圖像創建一個圖標。提供的圖像命名將從應用程序的包中加載,並將被屏蔽以符合系統定義的圖標style.So我怎樣才能以編程方式獲得UIApplicationShortcutIcon
的彩色圖像?如何將UIApplicationShortcutItem中的自定義圖像添加爲UIApplicationShortcutIcon?
2
A
回答
2
您可以從應用程序委託添加快捷圖標also.Here img_editProduct和img_Classifieds在添加自定義圖像。 xcassests文件
- (void)shortcutsWithIcon
{
@try
{
UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"img_editProduct"];
UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"img_Classifieds"];
UIMutableApplicationShortcutItem *item1 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.3dtouchApp.postAnItem" localizedTitle:@"Post an Item" localizedSubtitle:@"Add new product for sale" icon:icon1 userInfo:nil];
UIMutableApplicationShortcutItem *item2 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.3dtouchApp.LatestAds" localizedTitle:@"Latest Ads" localizedSubtitle:@"View top recent Ads" icon:icon2 userInfo:nil];
NSArray *items = @[item2, item1];
[UIApplication sharedApplication].shortcutItems = items;
}
@catch (NSException *exception) {
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (self.window.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
{
[self shortcutsWithIcon];
if ([item.type isEqualToString:@"com.3dtouchApp.postAnItem"])
{
***//Code for launch your screen***
}
if ([item.type isEqualToString:@"com.3dtouchApp.LatestAds"])
{
***//code for launch your screen***
}
}
return YES;
}
0
做的不到位的模板圖標的使用表情符號。當文本右對齊時,Emojis無法正確對齊 。此外,emojis是全綵色, ,而模板圖標應該是單色的。您可以從許多系統提供的模板圖標中選擇 ,也可以創建一個 自定義模板圖標。有關圖標大小,填充, 和定位的詳細指導,請從 https://developer.apple.com/design/downloads/Quick-Action-Guides.zip下載主屏幕快速操作圖標模板。 要了解有關設計模板圖標的更多信息,請參閱模板圖標。
根據上述文字,我不認爲有沒有辦法顯示彩色圖標。可能是我們會在未來的更新。
相關問題
- 1. UIApplicationShortcutItem - 我能否使用網絡作爲UIApplicationShortcutIcon下載的圖像?
- 2. 自定義UIApplicationShortcutIcon
- 3. 如何將自定義圖像添加到Xcode中的UITableviewController?
- 4. 將圖像添加到自定義baseadapter
- 5. 將圖像添加到自定義AlertDialog
- 6. 如何將圖像添加到自定義的WiX對話框?
- 7. 如何在Android中的自定義ListView中添加圖像?
- 8. 如何使用Branch.io將自定義圖像添加到鏈接?
- 9. android:如何將自定義圖像添加到小部件?
- 10. 如何將FBSDKLoginButton默認圖像添加到自定義UIButton?
- 11. 如何將圖像添加到自定義按鈕
- 12. 如何在CustomBox中添加自定義加載圖像?
- 13. 如何在Outlook自定義列中添加位圖圖像
- 14. 如何爲自定義UIToolBar添加背景圖像
- 15. 如何將自定義圖例添加到R中的圖形?
- 16. 如何將圖像添加到Android中的自定義列表視圖?
- 17. 將自定義圖像添加到導航抽屜的中心
- 18. 如何將自定義tileset添加爲mapbox.js圖層?
- 19. 我如何將多個圖像添加到自定義後在WordPress爲
- 20. 如何將UIBarButton圖像替換爲自定義圖像?
- 21. 向UIBarButtonItem添加自定義(Retina)圖像
- 22. 如何將自定義圖像添加到Mapview Swift ios中的註釋?
- 23. 如何將自定義多彩圖像添加到TabBarController中的tabBar?
- 24. 如何將自定義圖像字段添加到Magento中的類別?
- 25. 如何將自定義圖像按鈕添加到iPhone中的UINavigationBar sdk
- 26. 如何將函數添加爲jQuery中的自定義事件?
- 27. 如何MGWT的ImageButton添加自定義圖像
- 28. UISlider自定義:如何向自定義旋鈕圖像正確添加陰影
- 29. 將圖像添加到自定義列表視圖
- 30. 將自定義圖像添加到日曆視圖