Skip to content

Latest commit

 

History

History
118 lines (97 loc) · 4.03 KB

README.md

File metadata and controls

118 lines (97 loc) · 4.03 KB

GitHub platform GitHub version GitHub language GitHub license

AlternateIconName-objC

AlternateIconName for objective-C

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.

32b5f3c3c54af67507dbaeff58ab43fe

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’s Info.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]);
                                      }];

License

MIT License

Copyright (c) 2017 Tez Park

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE