UITabbar上显示小红点。
文章目录
如果有数字,直接使用 viewController.tabBarItem.badgeValue = @"1";
-
没有数字,自己往tabbar加subView。
需要注意的是坐标x,y一定要是整数,否则会有模糊。 UIImageView *dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"personinfo_unread@2x.png"]]; 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];
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论