1.设置当前页面的角标:
self.tabBarItem.badgeValue = @"66";
self.tabBarItem.badgeValue = nil;//清空
2.设置非当前页面的角标:
UITabBarController * root = self.tabBarController; // self当前的viewController
UITabBarItem * tabBarItem = [UITabBarItem new];
if (root.tabBar.items.count > 1) {
tabBarItem = root.tabBar.items[1];// 拿到需要设置角标的tabarItem
}
if (waitMeTotal > 0) {
tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld",waitMeTotal];
}else{
tabBarItem.badgeValue = nil;
}
网友评论