UITabbar上显示小红点。
1. 如果有数字,直接使用 viewController.tabBarItem.badgeValue = @"1";
2. 没有数字,自己往tabbar加subView。
需要注意的是坐标x,y一定要是整数,否则会有模糊。
UIImageView *pointImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"red_point@2x.png"]];
pointImage.backgroundColor = [UIColor clearColor];
pointImage.tag = RED_POINT_TAG;
CGRect tabFrame = tabbarController.tabBar.frame;
CGFloat x = ceilf(0.94 * tabFrame.size.width);
CGFloat y = ceilf(0.2 * tabFrame.size.height);
pointImage.frame = CGRectMake(x, y, 6, 6);
[tabbarController.tabBar addSubview:pointImage];