在info.plist文件中更新CFBundleIcons的值。如果您不确定此如何实现,可以使用以下代码示例从代码中添加图标。 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool{ // Override point for customization after application launch.
// Adding App Icons Dynamically if let shortcuts = Bundle.main.infoDictionary!["CFBundleIcons"] as? NSDictionary { if let primaryIcon = shortcuts["CFBundlePrimaryIcon"] as? NSDictionary { if let iconsArray = primaryIcon["CFBundleIconFiles"] as? NSArray { if let lastIcon = iconsArray.lastObject as? String { let iconPath = "(NSBundle.mainBundle().bundlePath)/(lastIcon)" let iconUrl = URL(fileURLWithPath: iconPath) let data = NSData(contentsOf: iconUrl)
if let image = UIImage(data: data! as Data) {
let icon = UIApplicationShortcutIcon(templateImageName: lastIcon)
let item = UIApplicationShortcutItem(type: "com.wordpress.tipsoholic.DynamicIcon2", localizedTitle: "Title