欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

设置桌面图标

程序员文章站 2022-05-31 15:36:51
...
+(void)setAppIconNumber:(NSInteger)num type:(int)type{
    if ([UIParam getIOSVersion]>8.0) {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    }
    
    UIApplication *app = [UIApplication sharedApplication];

    if (type == 0) {
        // 应用程序右上角数字
        app.applicationIconBadgeNumber += num;
    }else{
        app.applicationIconBadgeNumber  = num;
    }
}