zoukankan      html  css  js  c++  java
  • tabbar添加小红点

    系统方法:

    系统自带的方法可以显示具体的消息数量,这个就是苹果设备常见的小红点。实现思路如下:

     

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

    UITabBarItem *personCenterTabBarItem = [tabBarItems objectAtIndex:3];

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

     

    自定义方法:

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

     

    UIImageView *dotImage = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"red_point_small"]];

            dotImage.backgroundColor = [UIColorclearColor];

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

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

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

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

            [self.navigationController.tabBarController.tabBaraddSubview:dotImage];

     

     

    App的桌面应用图标上的消息提示,实现思路如下:

            if ([[XWGlobalHelper systemVersion] intValue] > 7.99 && [[XWGlobalHelper systemVersion] intValue] < 9.001) {

                

    //IOS8 需要 设置

    UIUserNotificationSettings *settings = [UIUserNotificationSettings

    settingsForTypes:UIUserNotificationTypeBadge categories:nil];

                [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

            }

            [UIApplication sharedApplication].applicationIconBadgeNumber = 3;

  • 相关阅读:
    return false 和 return true
    前端异常采集
    Performance — 前端性能监控利器
    正则笔记-忘记就来看
    JS中的正则应用
    iconfont的使用
    canvas笔记1
    树莓派3B安装DeBian 64位系统及其安装私有云网盘----可道云
    台灯改造【智能台灯】
    单片机C语言中标志位的经典应用
  • 原文地址:https://www.cnblogs.com/h-tao/p/5287175.html
Copyright © 2011-2022 走看看