zoukankan      html  css  js  c++  java
  • 小红点

    一.系统自带

     [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

        self.view.backgroundColor = [UIColor whiteColor];

        self.navigationItem.title = @"首页";

        UITabBarItem *item = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:1];

        self.tabBarItem = item;

        

    //    NSArray *tabBarItems = self.navigationController.tabBarController.tabBar.items;

    //    // 获取到需要展示消息的tabbarItem,属性badgeValue(标记个数)就是消息的条数

    //    UITabBarItem *personCenterTabBarItem = [tabBarItems objectAtIndex:3];

    //    personCenterTabBarItem.badgeValue = @"2"//显示消息条数为 2

        item.badgeValue = @"99+" 

    二.自定义

    //    自定义方法:

    //    自己将小红点图标放在想要显示的位置,控制UIImageViewhidden属性即可。实现思路如下:

        // 创建一个UIImageView,存放小红点图片

        UIImageView *dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"red_point_small"]];

        dotImage.backgroundColor = [UIColor redColor];

        // 获取tabbarItameframe

        CGRect tabFrame =self.navigationController.tabBarController.tabBar.frame;

        CGFloat x =ceilf(0.5 * tabFrame.size.width);

        CGFloat y =ceilf(0.1 * tabFrame.size.height);

        // 设置小红点图标的frame

        dotImage.frame =CGRectMake(x, y, 8,8);

        // 将小红点imageView添加到tabbar上面

        [self.navigationController.tabBarController.tabBar addSubview:dotImage];

     

    三.桌面icon图标红点

    //获取用户授权

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

            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];

            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

        }

        //注册消息推送

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

            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];

            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

            [[UIApplication sharedApplication] registerForRemoteNotifications];

        }

        //设置推送消息个数

        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:10];

        

     

     

  • 相关阅读:
    org.hibernate.HibernateException: No Session found for current thread
    TCP/IP协议 HTTP协议
    [ERROR][org.springframework.web.context.ContextLoader][main] Context initialization failed org.sprin
    oracle 导出表结构和数据,使用plsql
    jar包里查找指定的class文件,排查是否存在或重复,工具软件:Java Class Finder
    maven手动安装jar到本地仓库
    The reference to entity “idNo” must end with the ';' delimiter 异常处理
    activeMQ下载,安装,启动,关闭
    Oracle错误:ORA-01033
    -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
  • 原文地址:https://www.cnblogs.com/daxueshan/p/5849339.html
Copyright © 2011-2022 走看看