角标

iOS 8角标显示需要用户授权,可在应用启动时请求授权:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

if ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0)

{

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;

UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

}

else

{

UIRemoteNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];

}

return YES;

}


设置方法:

[UIApplicationsharedApplication].applicationIconBadgeNumber = 10;

你可能感兴趣的:(角标)