Yes, this is possible since iOS 10.3.
First, you need to define all alternative icons in your Info.plist file, you can't fetch them dynamically.
In the example below 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
}
}
Result:
The gif is from a Medium article by Julien Quéré.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…