5

Is it possible to apply the alternative icon to the iOS application?

 3 years ago
source link: https://www.codesd.com/item/is-it-possible-to-apply-the-alternative-icon-to-the-ios-application.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Is it possible to apply the alternative icon to the iOS application?

advertisements

I need to change the app icon based on region, is this possible?


Yes, this is possible since iOS 10.3.

First, you need to define all alternative icons in your plist file (so you can't fetch icons dynamically!). 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
    }
}

Result:

Source


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK