iOS如何自定义的设置UITabbarItem的badge
来源:互联网 发布:php实现硬件设备对接 编辑:程序博客网 时间:2024/05/29 11:56
本文的代码实现效果如下:
除了第三个tabbarItem显示数字,其他的都显示红点
代码如下:
//tabbar消息未读数量- (void)showUnreadCountViewItemNO:(NSInteger)index unReadCountSum:(NSInteger)unReadCountSum { UILabel *bageView = (UILabel*)[self.tabBarController.tabBar subviewWithTag:1000+index]; if(unReadCountSum){ if(!bageView){ bageView = [[UILabel alloc] init]; bageView.backgroundColor = kDefaultColor; bageView.tag = 1000+index; [self.tabBarController.tabBar addSubview:bageView]; if(index == 2){ bageView.frame=CGRectMake(WIDTH/4/2+WIDTH/4*index+8, 4, 16, 16); [CALayer updateControlLayer:bageView.layer radius:8 borderWidth:0 borderColor:nil]; bageView.textAlignment = NSTextAlignmentCenter; bageView.textColor = WHITE_COLOR; }else{ bageView.frame=CGRectMake(WIDTH/4/2+WIDTH/4*index+8, 4, 10, 10); [CALayer updateControlLayer:bageView.layer radius:5 borderWidth:0 borderColor:nil]; } } if(index == 2){ NSString *numStr; if(unReadCountSum>100){ numStr = @"99+"; bageView.font = FONT_SYSTEM_SIZE(10); }else{ numStr = [NSString stringWithFormat:@"%ld", (long)unReadCountSum]; bageView.font = FONT_SYSTEM_SIZE(12); } bageView.text = numStr; [UIApplication sharedApplication].applicationIconBadgeNumber = unReadCountSum; } }else{ if(bageView){ [bageView removeFromSuperview]; } if(index==2){ [UIApplication sharedApplication].applicationIconBadgeNumber = unReadCountSum; } }}
0 0
- iOS如何自定义的设置UITabbarItem的badge
- IOS上最简单的自定义Badge
- iOS开发--一些UITabBarItem属性的设置
- UITabBarItem文字的设置
- ios 两种方法设置tabBar的UITabBarItem
- 设置按钮右上角的badge
- ios7设置UITabbarItem的样式
- iOS 7 的变化,UITabBarItem
- 自定义UITabbarItem的title字体颜色
- UITabBarItem中图片和文字的设置
- 设定应用程式上的 Badge -- IOS
- iOS 关于UITabBarItem 选中图片的颜色以及标题的颜色设置
- ios之UITabBarItem显示真实自定义的图片而非颜色填充
- ios之UITabBarItem显示真实自定义的图片而非颜色填充
- iOS开发- UITabBarItem自定义图片
- IOS 7修改UITabbar背景图片、UITabBarItem图片以及UITabBarItem的文字颜色.
- IOS7下的UITabBarItem 的背景图片的设置
- 对于UIToolbar,UINavigationBar,UITabBar,UIBarButtonItem,UITabBarItem这几种控件的自定义
- 仿支付宝咻一咻效果
- 常见证书格式转换
- 文本编辑器
- 音视频的帧
- Android Eclipse Templates 快速插入代码设置方法
- iOS如何自定义的设置UITabbarItem的badge
- Android输入法界面管理(打开/关闭/状态获取)
- 顺序查找
- Unity如何使用WWW类和协程完成图片、视频下载播放(一)
- sqlserver翻页
- 参数数据类型 sql_variant 对于 like 函数的参数 1 无效。
- 我的第一篇内容
- SQLiteDatabaseLockedException
- hello