如何在objective-c中设置标签栏的标记?

时间:2021-12-27 04:15:16

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.

我想将通知放在app的选项卡栏中,以显示为购物列表所选择的项目数量。有没有办法在app的标签栏中添加通知?

4 个解决方案

#1


31  

You mean the badge? Do something like (where self is a UIViewController):

你的意思是徽章吗?做一些类似(self是一个UIViewController)的事情:

[[self tabBarItem] setBadgeValue:@"42"];

#2


3  

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];

2。[[[]][[[]][[[]][[[]][[[]][[][[[]][[]][[][[]][[][[]][[[[]][[][[]][[][[]][[[

and if you want to set by storyboard please refer this image.

如果你想通过故事板来设置请参考这个图像。

如何在objective-c中设置标签栏的标记?

Hope this will helps. Thanks

希望这将帮助。谢谢

#3


1  

You can set the badgeValue property on a UITabBarItem to present the user with a small red badge on that item.

您可以在UITabBarItem上设置badgeValue属性,以向用户显示该项目上的小红色标记。

#4


0  

I did it using:

我使用:

self.navigationController.tabBarItem.badgeValue = @"2";

#1


31  

You mean the badge? Do something like (where self is a UIViewController):

你的意思是徽章吗?做一些类似(self是一个UIViewController)的事情:

[[self tabBarItem] setBadgeValue:@"42"];

#2


3  

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];

2。[[[]][[[]][[[]][[[]][[[]][[][[[]][[]][[][[]][[][[]][[[[]][[][[]][[][[]][[[

and if you want to set by storyboard please refer this image.

如果你想通过故事板来设置请参考这个图像。

如何在objective-c中设置标签栏的标记?

Hope this will helps. Thanks

希望这将帮助。谢谢

#3


1  

You can set the badgeValue property on a UITabBarItem to present the user with a small red badge on that item.

您可以在UITabBarItem上设置badgeValue属性,以向用户显示该项目上的小红色标记。

#4


0  

I did it using:

我使用:

self.navigationController.tabBarItem.badgeValue = @"2";