info.plist文件添加字段。可添加多个待替换图标,需要确保对应key值与value值均为图标名称,并将图标拖进工程。最后一个value值为图标大小,低型号会自动压缩展示
需要实现的代码:
- (void)changeIconWithIconName:(NSString *)iconName{
BOOLresult = [UIApplicationsharedApplication].supportsAlternateIcons;
if(result) {
NSLog(@"you can change this APP's icon");
}else{
NSLog(@"you can't change this APP's icon");
return;
}
NSString*name = [UIApplicationsharedApplication].alternateIconName;
if([nameisEqualToString:iconName]) {
return;
}else{
[[UIApplicationsharedApplication]setAlternateIconName:iconNamecompletionHandler:^(NSError*_Nullableerror) {
NSLog(@"%@",error);
}];
}
}
第一次写简书,代码格式很烦啊。
网友评论