IOS8.0以前直接显示:
UIApplication *application=[UIApplication sharedApplication]; //设置图标上的更新数字 application.applicationIconBadgeNumber=3;
IOS8.0以后需加上以下代码让用户选择是否显示
float versionNumber=[[[UIDevice currentDevice] systemVersion] floatValue]; if (versionNumber >= 8.0) {//通知设置 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil]; //接收用户的选择 [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; }
类似下面效果:
时间: 2024-10-23 06:08:34