gpt4 book ai didi

ios - 是否可以将替代图标应用于 iOS 应用程序?

转载 作者:技术小花猫 更新时间:2023-10-29 10:41:29 27 4
gpt4 key购买 nike

我需要根据地区更改应用程序图标,这可能吗?

最佳答案

是的,自 iOS 10.3 以来这是可能的。

首先,您需要在 Info.plist 文件中定义所有替代图标,您不能动态获取它们。

在下面的示例中,我们定义了 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
}
}

结果:

Gif showing the icon changing in response to a segmented control

动图来自a Medium article by Julien Quéré .

关于ios - 是否可以将替代图标应用于 iOS 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41950994/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com