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;

  • 相关阅读:
    一些关于微电子方面的笔试题
    [JavaScript]Redeclaring variable
    [JavaScript]How to run Jasmine in Intellij/WebStorm?
    [JavaScript] Use `+` opertor to add one string and one number
    [CoffeeScript]CoffeeScript学习笔记
    Study Note for grunt
    grunt.js
    [转]Vim常用命令速查
    如何在Web Page里体验CoffeeScript的 功能
    [JavaScript] 如何使用Ruby gem运行jasmine test case
  • 原文地址:https://www.cnblogs.com/h-tao/p/5287175.html
Copyright © 2011-2022 走看看