美文网首页
tabbar添加小红点

tabbar添加小红点

作者: 雷霸龙 | 来源:发表于2017-05-05 18:27 被阅读197次

    添加小红点,思路就是在tabbar上添加一个UIImageView,给个红色的小圆点的图片即可

    UIImageView *dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"new_inform_remind_me"]];
    dotImage.backgroundColor = [UIColor clearColor];
    dotImage.tag = 101;
    CGRect tabFrame = self.tabBar.frame;
    CGFloat x = ceilf(0.65 * tabFrame.size.width);
    CGFloat y = ceilf(0.1 * tabFrame.size.height);
    dotImage.frame = CGRectMake(x, y, 6, 6);
    [self.tabBar addSubview:dotImage];
    
    [dotImage release];
    

    如果想要小红点显示数字,直接用系统的tabbarItem的badgeValue属性就可以实现

    setting.tabBarItem.badgeValue = [NSString stringWithFormat:@"%zd", 8];
    

    后面的数字,你可以根据需要来显示。

    相关文章

      网友评论

          本文标题:tabbar添加小红点

          本文链接:https://www.haomeiwen.com/subject/ffystxtx.html