这可以将替代图标应用于iOS应用程序吗? [英] Is this possible to apply the alternative icon to the iOS application?
本文介绍了这可以将替代图标应用于iOS应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要根据地区更改应用图标,这可能吗?
I need to change the app icon based on region, is this possible?
推荐答案
是的,这是可能的,因为 iOS 10.3 。
Yes, this is possible since iOS 10.3.
首先,您需要在Info.plist文件中定义所有替代图标,但无法动态获取它们。
First, you need to define all alternative icons in your Info.plist file, you can't fetch them dynamically.
例如,我们在这里定义了2个替代图标:de和fr:
For example, here we define 2 alternative icons: "de" and "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>
然后你可以根据你喜欢的任何事情设置图标名称(游戏进度,天气状况,高级用户)等)。要更改图标,请使用:
Then you can set the icon name based on anything you like (game progress, weather conditions, premium user, etc.). To change the icon use:
UIApplication.shared.setAlternateIconName("de") { (error) in
if let error = error {
print("err: \(error)")
// icon probably wasn't defined in plist file, handle the error
}
}
结果:
gif来自JulienQuéré的中篇文章。
这篇关于这可以将替代图标应用于iOS应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文