1.info.plist的设置
由于不能复制出来这些格式,为了避免写错,特地把这些可以单独复制出来
CFBundleIcons、CFBundleAlternateIcons、changedIcon、CFBundleIconFiles、changedIcon、UIPrerenderedIcon、CFBundlePrimaryIcon、CFBundleIconFiles、Icon-60
2.代码
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event
{
if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_3) {
if ([[UIApplication sharedApplication] supportsAlternateIcons]) {//判断是否支持
NSLog(@"can");
}else{
NSLog(@"no");
}
NSString *alternateIconName = [UIApplication sharedApplication].alternateIconName;//获取备用的icon
if (alternateIconName) {//如果alternateIconName 为空的话,可以设置默认的icon
[[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) {
}];
}else{
/*
如果alternateIconName 为空的话,可以设置备用的icon,这里的AlternateIconName,要是资源icon的名字
*/
[[UIApplication sharedApplication] setAlternateIconName:@"changedIcon" completionHandler:^(NSError * _Nullable error) {
if (error) {
}else{
NSLog(@"ok");
}
}];
}
}
}
网友评论