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;

  • 相关阅读:
    Class attributes
    Card objects
    Exercises
    Type-base dispatch
    Operator overloading
    The str method
    loadrunner协议开发
    nmon分析与详解
    如何判断CPU、内存、磁盘的性能瓶颈?
    用友NC客户端地址
  • 原文地址:https://www.cnblogs.com/h-tao/p/5287175.html
Copyright © 2011-2022 走看看