Info.plist
CFBundleIcons CFBundlePrimaryIcon CFBundleIconFiles 原AppIcon图标名 CFBundleAlternateIcons icon01 CFBundleIconFiles AppIcon图标名2 icon02 CFBundleIconFiles AppIcon图标名3
2.将所有AppIcon放入工程中(不要放在Assets.xcassets)
3.代码
// 更换 if ([UIApplication sharedApplication].supportsAlternateIcons) { [[UIApplication sharedApplication] setAlternateIconName:图标名 completionHandler:^(NSError * _Nullable error) { if (!error) { NSLog(@"success:%@",图标名); }else{ NSLog(@"error:%@",error); } }]; } else { NSLog(@"不能更换icon"); return; } } // 还原 if ([UIApplication sharedApplication].alternateIconName != nil) { // 图标被替换过 // 重置icon [[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) { if (!error) { NSLog(@"success"); } else { NSLog(@"error:%@",error); } }]; }
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。