Kli*_*akM 35
是的,这可以从iOS 10.3开始.
首先,您需要在Info.plist文件中定义所有替代图标,您无法动态获取它们.
例如,这里我们定义了两个替代图标:"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>
Run Code Online (Sandbox Code Playgroud)
然后,您可以根据您喜欢的任何内容(游戏进度,天气状况,高级用户等)设置图标名称.要更改图标,请使用:
UIApplication.shared.setAlternateIconName("de") { (error) in
if let error = error {
print("err: \(error)")
// icon probably wasn't defined in plist file, handle the error
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
这张GIF来自JulienQuéré的中篇文章.
| 归档时间: |
|
| 查看次数: |
2860 次 |
| 最近记录: |