应用图标上的数字

文档注释

/**
set to 0 to hide. default is 0. In iOS 8.0 and later,
your application must register for user notifications
using -[UIApplication registerUserNotificationSettings:]
before being able to set the icon badge.
*/
// 应用头像上的数字 默认情况下为0 ,没有数字
// 如果不是0 就会显示出来

代码

// iOS 8.0 之后修改应用图标上的数字,需要获取请求用户的授权,以下是授权代码。

UIUserNotificationCategory *category = [[UIUserNotificationCategory alloc] init];
NSSet *set = [NSSet setWithObject:category];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:set];
[app registerUserNotificationSettings:settings];

app.applicationIconBadgeNumber = 10;

运行后的效果

应用图标上的数字_第1张图片
Snip20160523_8.png

你可能感兴趣的:(应用图标上的数字)