我一直在尝试使用 CFBundleAlternateIcons 更改我的应用程序图标,但没有任何反应。我实际上正在使用 Flutter SDK 的插件 -flutter_dynamic_icon
当我使用插件更改图标时,它会显示“应用程序图标更改成功”,就好像没有任何问题一样。
在进行了一些故障排除后,我还尝试在预览中重新保存图标以确保它们是 PNG 文件,并删除它们的 alpha 通道,结果没有任何变化。
我究竟做错了什么?是 Info.plist 问题吗?我的图标是否保存不正确?我是否错误地要求更改图标?
这就是我尝试更改 dart lang 中的图标的方式:
try {
if (await FlutterDynamicIcon.supportsAlternateIcons) {
await FlutterDynamicIcon.setAlternateIconName("dark");
print("App icon change successful");
return;
}
} on PlatformException {} catch (e) {
print("icon couldn't be changed");
}
这就是我所看到的,不要介意我单击以更改为dark
图标或light
图标。
这是我的 Info.plist / 文件结构:
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>light</key>
<dict>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>light</string>
</array>
</dict>
<key>dark</key>
<dict>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>