简体   繁体   English

由Interface Builder生成的TabBar上的徽章

[英]Badge on TabBar when built by Interface Builder

Is it possible to programmable set a badge value on a TabBar which is made in Interface Builder (Xcode4). 是否可以在Interface Builder(Xcode4)中制作的TabBar上可编程设置徽章值。 I have four tabs and I would like to have a badge on the forth tab if there is unread items in the inbox that is behind the tab. 我有四个标签,如果该标签后面的收件箱中有未读项目,则希望在第四个标签上有一个徽章。

Or do I have to rebuild the tabbar by code to be able to do this? 还是我必须通过代码重新构建选项卡才能做到这一点?

Thanks for any thoughts on this. 感谢您对此的任何想法。

You can set it as - 您可以将其设置为-

UITabBarItem *tbi = (UITabBarItem*)[[[self.tabBarController tabBar] items] objectAtIndex:3];

[tbi setBadgeValue:@"1"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM