UITabbar 显示小红点 (消息提示)
2015-07-03 10:45
519 查看
原文:http://www.cocoachina.com/bbs/read.php?tid-294947.html
UITabbar 显示小红点 (消息提示)
1. 如果有数字,直接使用 viewController.tabBarItem.badgeValue = @"1";
2. 没有数字,自己往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];
UITabbar 显示小红点 (消息提示)
1. 如果有数字,直接使用 viewController.tabBarItem.badgeValue = @"1";
2. 没有数字,自己往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];
相关文章推荐
- 设计师成长的五个阶段。
- 如何ScrollView在XIB或者Storyboard中设置约束并实现翻页滚动效果
- StringBuilder与StringBuffer联系与区别
- 自已实现一个UI库
- 完全代码实现UITableView下拉更新,异步请求数据
- UIScrollView的简单使用 以及一些常用属性
- UIautomator运行步骤
- illegal to have multiple occurrences of contentType with different values (old: text/html; charset=UTF-8, new: text/html; charset=utf-8)
- Kendo UI treeview 的使用
- stl之deque双端队列容器
- String,StringBuffer以及StringBuilder的区别
- MSQL优化基础(frequence直方图选择率)
- Kendo UI k-template 的使用
- projecteuler---->problem=14----Longest Collatz sequence
- 详解 UIView 的 Tint Color 属性
- 用 OpenCV 实现 Guided Filter
- StringBuilder is mutable
- UINavigationController纯代码实现细节提示
- 记录:sea.js和require.js配置 与 性能对比
- NGUI长按事件