Directly set Tabbaritem.badgevalue no effect, find the reason for half a day found Viewcontroller was Navigationviewcontroller wrapped
This setting is required:
1 self.navigationController.tabBarItem.badgeValue = [[NSString Alloc]initwithformat:@ '%d ", Count];
1. If there are numbers, use Viewcontroller directly. Tabbaritem.badgevalue = @ "1";
2. No numbers, Tabbar and Subview.
It is important to note that coordinates x, y must be integers, otherwise there will be ambiguity .
Uiimageview *dotimage = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "[email protected]"];
Dotimage.backgroundcolor = [Uicolor Clearcolor];
Dotimage.tag = Red_dot_tag;
CGRect tabframe = tabbarController.tabBar.frame;
CGFloat x = Ceilf(0.94 * tabFrame.size.width);
CGFloat y = ceilf(0.2 * tabFrame.size.height);
Dotimage.frame = CGRectMake (x, Y, 6, 6);
[Tabbarcontroller.tabbar Addsubview:dotimage];
[Dotimage release];
iOS Development--tarbaritem upper right display Badgevalue