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;

  • 相关阅读:
    Docker简单的使用命令
    iPad 3g版完美实现打电话功能(phoneitipad破解)
    提供一个免费的CSDN下载账号
    2011年一次面试的实际记录
    VC皮肤库SkinSharp 1.0.6.6的使用
    oracle 数组
    从网页抓取数据的一般方法
    IJ:Idea 常用代码
    un-公司-Continental AG(大陆集团):百科
    un-公司-维珍集团:百科
  • 原文地址:https://www.cnblogs.com/h-tao/p/5287175.html
Copyright © 2011-2022 走看看