iOS 10.3 加入了了更换应用图标的新功能,开发者可以为应用提供多个应用图标选择。用户可以自由的在这些图标之间切换,下面具体查看切换步骤。


1.先把你需要的所有图片都导入项目中(比例为1:1)

ios appStore 更换多个icon

2.plist文件配置,添加Icon files (iOS 5)类型为Dictionary

ios appStore 更换多个icon

3.点开Icon files (iOS 5),里面有Primary Icon,Newsstand Icon两个key,Primary Icon 里面的图片为AppIcon默认图片。

ios appStore 更换多个icon

4.Icon files (iOS 5)里面创建一个CFBundleAlternateIcons,类型为Dictionary

ios appStore 更换多个icon

5.点击开CFBundleAlternateIcons,按照如图所示的添加,我添加了三个分别是icon1,icon2,icon3(这个名字是自己写的),它们对应的本地图片名字是2,3,4。添加时数据类型对应一至,

ios appStore 更换多个icon

6.执行代码

- (IBAction)one:(id)sender {

    [selfchangeImageNames:@"icon1"];

}


- (IBAction)two:(id)sender {

    [selfchangeImageNames:@"icon2"];

}


- (IBAction)three:(id)sender {

    [selfchangeImageNames:@"icon3"];

}


-(void)changeImageNames:(NSString *)name{


    if ([UIApplicationsharedApplication].supportsAlternateIcons) {//来判断是否支持换应用图标

        

        //setAlertnateIconName方法有二个参数

        //第一个参数是要换图标的名字(此名字不是图片的原始名字),如果写nil,系统默认是最初图标名字

        //第二个参数是方法执行的回调

        [[UIApplicationsharedApplicationsetAlternateIconName:name completionHandler:^(NSError *_Nullable error) {

            if (error) {

               NSLog(@"失败");

            }else{

               NSLog(@"成功");

            }

            

        }];

    }


}



具体代码请去此网址下载:https://github.com/CKDemo/-


相关文章:

  • 2021-07-24
  • 2022-12-23
  • 2021-05-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-09-27
  • 2021-11-17
  • 2021-12-22
  • 2021-08-19
  • 2022-12-23
相关资源
相似解决方案