Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Latest commit

 

History

History
64 lines (57 loc) · 1.5 KB

README.md

File metadata and controls

64 lines (57 loc) · 1.5 KB

AlternateIconExample

Example of ios 10.3+ alternate icons usage.

alternateicon

Requirements

  • iOS 10.3 and above
  • Set of icons in 3 sizes: 60px, 120px, 180px (@1x, @2x, @3x)

Step by step

  1. Add icon images in project. Not in Assets.xcassets
  2. Add icons to info.plist
	<key>CFBundleIcons</key>
	<dict>
		<key>CFBundleAlternateIcons</key>
		<dict>
			<key>icon-1</key>
			<dict>
				<key>CFBundleIconFiles</key>
				<array>
					<string>icon-1</string>
				</array>
				<key>UIPrerenderedIcon</key>
				<false/>
			</dict>
			
      ...
      
			<key>icon-N</key>
			<dict>
				<key>CFBundleIconFiles</key>
				<array>
					<string>icon-N</string>
				</array>
				<key>UIPrerenderedIcon</key>
				<false/>
			</dict>
		</dict>
		<key>CFBundlePrimaryIcon</key>
		<dict>
			<key>CFBundleIconFiles</key>
			<array>
				<string>AppIcon60x60</string>
			</array>
		</dict>
	</dict>
  1. Set icon by name (string) or nil to reset to default
// Check compatibility before set
    if([UIApplication sharedApplication].supportsAlternateIcons){
        
        // Set by name or nil to reset
        [[UIApplication sharedApplication] setAlternateIconName:name completionHandler:^(NSError * _Nullable error) {
            if(error){
                NSLog(@"error = %@", error.localizedDescription);
            }
        }];
    }else{
        NSLog(@"AlternateIcons unsupported");
    }