Reputation: 1364
I want to put the notification in the tab bar of the app to show the number of item selected for the shopping list. Is there any way to add the notification in the tab bar of app.
Upvotes: 17
Views: 9057
Reputation: 797
On the storyboard you have to select your navigation view controller if you have and then open your Property window and set Badge according to your requirement.
if you want to set programmatically
1. find your tabbar Item by viewcontroller
# badge=what you want to set.
2.[[[[self tabBarController] tabBar] items] objectAtIndex:1] setBadgeValue:badge];
and if you want to set by storyboard please refer this image.
Hope this will helps. Thanks
Also if you want to use in swift. Below code will work for you
[[self tabBarItem] setBadgeValue:@"42"];
Upvotes: 4
Reputation: 648
I did it using:
self.navigationController.tabBarItem.badgeValue = @"2";
Upvotes: 1
Reputation: 85532
You can set the badgeValue property on a UITabBarItem to present the user with a small red badge on that item.
Upvotes: 1
Reputation: 243156
You mean the badge? Do something like (where self
is a UIViewController
):
[[self tabBarItem] setBadgeValue:@"42"];
Upvotes: 33