[英]TabviewController How to show the unread messages like as badges?
您需要简单的设置badgeValue
财产tabBarItem
了点。
NSString *badgeVal = @"5"; //Unread message count
[[[[self.tabBarController viewControllers] objectAtIndex:2] tabBarItem] setBadgeValue:badgeVal];
注意:我可以使用objectAtIndex:2
访问第3个ViewController
因为您想为第3个UITabBarItem
设置徽章。
好吧,只需使用badgeValue
属性UITabbarItem
:
https://developer.apple.com/reference/uikit/uitabbaritem/1617065-badgevalue
尝试这个。
NSString *badgeVal = @"5"; //Unread message count
[[self navigationController] tabBarItem].badgeValue = badgeVal;
要么
[[self.tabBarController.tabBar.items objectAtIndex:<your item position>] setBadgeValue:[NSString stringWithFormat:@"%d",badgeVal]]
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.