Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将UITabBarController用于 iOS 应用程序。它有 3 个标签。例如 tab1(当前选项卡)、tab2 和 tab3。单击 tab1 上的按钮时,我想在 tab3 图标上放一个红色小徽章。有什么办法可以添加吗?
UITabBarItems 有一个 badgeValue 属性。当您的委托方法被触发时,您可以设置它。
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;
您可以从 tabBarController 获取 TabBarItem #3
[tabBarController.tabBar.items objectAtIndex:2];