Programming/iOS - ObjC
[AppIcon] iOS 10.3 Dynamic Alternate Icon Name (동적으로 앱 아이콘 변경)
Tez.Park
2017. 3. 28. 17:52
Info
In iOS 10.3, the function to change app icons has been added, which allows you to change the icon without updating the app.

How to add
In Project
- minimum target version : iOS 10.3
- Add the alternate icons onto project
- I haven't found a way to use Assets yet
- Add
CFBundleIcons
parameter in app’sInfo.plist
file
// Info.plist
...
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>icon_type_1</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon1</string> // <- added the alternate icon name
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>icon_type_2</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon2</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>icon_type_3</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon3</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string> // <- Assets AppIcon
</array>
</dict>
</dict>
...
In Code
- Setting the alertnate Icon
if ([[UIApplication sharedApplication] supportsAlternateIcons] == NO)
return;
[[UIApplication sharedApplication] setAlternateIconName:@"icon_type_1" //AlternateIcons key name
completionHandler:^(NSError * _Nullable error) {
NSLog(@"%@", [error description]);
}];
- Reset to the primary icon
if ([[UIApplication sharedApplication] supportsAlternateIcons] == NO)
return;
[[UIApplication sharedApplication] setAlternateIconName:nil
completionHandler:^(NSError * _Nullable error) {
NSLog(@"%@", [error description]);
}];
반응형