In iOS 10.3 Apple added API for alternating icon. I need to change app icon to icon generated in a runtime. Is there a way to generate CFBundleIcon
in a runtime so I could make icon change?
Asked
Active
Viewed 96 times
1

mangerlahn
- 4,746
- 2
- 26
- 50

ilyailya
- 318
- 4
- 17
-
check this link "http://stackoverflow.com/questions/41950994/is-this-possible-to-apply-the-alternative-icon-to-the-ios-application". Nice description. – Er.Shreyansh Shah Apr 15 '17 at 09:32
-
1No, you can only select from one of the icons that are included with your original bundle. – Paulw11 Apr 15 '17 at 12:15
1 Answers
0
Make changes in info plist:-
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>ALTERNATE_APP_ICON_NAME</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>ALTERNATE_APP_ICON_NAME</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string>
</array>
</dict>
</dict>
Once you made changes in info plist. You need to add following code:
Objective c:-
[[UIApplicationsharedApplication] setAlternateIconName:@"ALTERNATE_APP_ICON_NAME"completionHandler:^(NSError * _Nullable error) {
NSLog(@"Error...");
}];
Swift:
if UIApplication.shared.supportsAlternateIcons{
UIApplication.shared.setAlternateIconName("alternater2", completionHandler: { (error) in
print(error ?? "")
})
}

Nishant Sharma
- 189
- 2
- 6
-
This doesn't solve OP's problem. They are specifically asking about setting an icon created dynamically (not in the app's bundle). This code cannot do that, and there's no way to change the app icon to an un-bundled one. – Andy Ibanez Feb 21 '20 at 21:14