Dynamic change the App Icon

From iOS 10.3 Apple had added:

1
>var supportsAlternateIcons: Bool

A Boolean value indicating whether the app is allowed to change its icon.

1
>var alternateIconName: String?

The name of the icon being displayed for the app.

1
>func setAlternateIconName(String?, completionHandler: ((Error?) -> Void)?)

Changes the app’s icon.

3 things will allow us to change the App Icon dynamic.

We can change the icon only if the value of the supportsAlternateIcons property is true.
We must declare our app’s primary and alternate icons using the CFBundleIcons key of our app’s Info.plist file.
We can check keys here https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102043

Reference: https://medium.com/ios-os-x-development/dynamically-change-the-app-icon-7d4bece820d2

© 2020 Vien's Blog All Rights Reserved.
Theme by hiero