How to set badgevalue in tabbar on iphone?

I use the following code to set a badgevalue in the current tab bar, but it is not visible in the tab bar

self.navigationController.tabBarItem.badgeValue = @"1"

What is the correct way to put the value of an icon in a tab bar.

+3
source share
2 answers

Did you find out why this one self.navigationController.tabBarItem.badgeValue = @"1"didn't work? I have the same problem, but I do not know why. But this is how it works:

[[[[self tabBarController] tabBar] items] objectAtIndex:0] setBadgeValue:@"AB"];
+2
source

This is how I access the badgeValue icon on tabBarItem:

UITabBarItem * tabBarItem = (UITabBarItem *)[aTabBarController.tabBar.items objectAtIndex:1];
tabBarItem.badgeValue = @"1";
+3
source

Source: https://habr.com/ru/post/1735705/


All Articles