zoukankan      html  css  js  c++  java
  • iOS开发--tarBarItem右上方显示badgeValue

    直接设置tabBarItem.badgeValue没有效果,找原因半天发现ViewController被NavigationViewController包着

    需这样设置才行:

    1 self.navigationController.tabBarItem.badgeValue = [[NSString alloc]initWithFormat:@"%d",count];

    1. 如果有数字,直接使用 viewController.tabBarItem.badgeValue = @"1";

    2. 没有数字,自己往tabbar加subView。

        需要注意的是坐标x,y一定要是整数,否则会有模糊

            UIImageView *dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"personinfo_unread@2x.png"]];

            dotImage.backgroundColor = [UIColor clearColor];

            dotImage.tag = RED_DOT_TAG;

            CGRect tabFrame = tabbarController.tabBar.frame;

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

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

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

            [tabbarController.tabBar addSubview:dotImage];

            [dotImage release];

  • 相关阅读:
    kali2018 安装****
    IIS PUT
    解析漏洞总结
    深入理解MVC
    Linux常用命令整理
    nginx视频直播/点播服务干货分享
    记因PHP的内存溢出导致的事故之解决
    五环之歌之PHP分页
    phpstorm 2017.1 激活
    拉伸收缩广告
  • 原文地址:https://www.cnblogs.com/feiling/p/4703911.html
Copyright © 2011-2022 走看看