[关闭]
@qixingguaizhuang 2016-05-26T09:27:47.000000Z 字数 311 阅读 713

badgeValue 的小技巧- iOS

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

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

totleUnreadCounts 为消息个数

    if (totleUnreadCounts > 0) {
       self.navigationController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld", totleUnreadCounts];
    }else{
         self.navigationController.tabBarItem.badgeValue = nil;
    }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注