美文网首页
badgeValue 的小技巧- iOS

badgeValue 的小技巧- iOS

作者: 骑行怪状 | 来源:发表于2016-05-26 17:27 被阅读4004次

pragma mark -- 角标提示 如果大于 0 显示,否则隐藏

我们项目中会使用到 badgeValue 用于提醒个数,会遇到变为 0 后,badgeValue 隐藏的问题,可以加一个判断实现。

totleUnreadCounts 为消息个数

    if (totleUnreadCounts > 0) {
       self.navigationController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld", totleUnreadCounts];
    }else{
         self.navigationController.tabBarItem.badgeValue = nil;
    }

相关文章

网友评论

      本文标题:badgeValue 的小技巧- iOS

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