这是可能的应用替代图标的iOS应用程序?
我需要更改基于区域的应用程序图标,这可能吗?
是的,这是可能的,因为从iOS 10.3
。
首先,你需要在Info.plist
文件中定义所有的替代图标(所以你不能dynamic获取图标!)。 例如,在这里我们定义了2个可选的图标: de
和fr
:
<key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcons</key> <dict> <key>de</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_de</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>fr</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_fr</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> </dict> <key>CFBundlePrimaryIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_none</string> </array> </dict> </dict>
然后,您可以根据您喜欢的任何设置(游戏进度,天气状况,高级用户等)设置图标名称。 要更改图标使用:
UIApplication.shared.setAlternateIconName("de") { (error) in if let error = error { print("err: \(error)") // icon probably wasn't defined in plist file, handle the error } }
结果:
资源
此function在10.3(testing版)
讨论使用此方法将应用程序的图标更改为主图标或其备用图标之一。 只有当supportsAlternateIcons属性的值为true时,才能更改图标。
您必须使用应用Info.plist文件的CFBundleIcons键声明应用的主要和备用图标。 有关如何为应用程序configuration备用图标的信息,请参阅“信息属性列表项参考”中关于CFBundleIcons项的描述。
看一眼:
苹果文档
多个App Store条目
app store中可能有多个不同的应用,主要因应用图标和app store描述而异。
其他人指出,可以从iOS 10.3更改应用程序图标。 我不知道这个,很酷! 我会在这里保留这个答案作为替代。