UI学习
来源:互联网 发布:网络品牌营销策略 编辑:程序博客网 时间:2024/05/16 01:10
day7 UITabBarController
UITabBarController
标签控制器
系统tabBarItem
1. UITabBarController
UITabBarItem
代理方法
NSUserDefaults
System item:
UITabBarItem alloc initWithTabBarSystemItem:tag:
We can’t set the title and image if use the systemItem
用系统预置好item无法设置标题和图片
Noted the loadView viewDidLoad and willWillAppear executed only for current controller
.moreNavigationController not in viewControllers
selectedIndex
selectedViewController
delegate方法的使用
NSUserDefault的使用
// 注:住偏好设置里面存的值比较有限,只支持以下几种:
// Array Dictionary BOOL Data Date Number String简单的类型
// [userDefault setBool:(BOOL) forKey:(NSString *)];
// [userDefault boolForKey:(NSString *)]
// [userDefault setInteger:(NSInteger) forKey:(NSString *)];
// [userDefault integerForKey:(NSString *)]
// 往偏好设置中存储Data不推荐用
// 偏好设置使用场景是一些简单的用户操作,设置等,不宜存储大容量和复杂的数据
// 注:往偏好里面基于同一个key赋值会把原来相同key对应的值覆盖掉
——————————————————————————————
2. 定制TabBarController & item
项目爱限免界面搭建

NSArray *commonImgNames = @[@"tabbar_limitfree", @"tabbar_reduceprice", @"tabbar_appfree", @"tabbar_subject", @"tabbar_rank"];
NSArray *titles = @[@"限免", @"降价", @"免费", @"专题", @"热榜"];
设置
vc.tabBarItem.image
// vc.title = @“1512棒棒哒”;
vc.tabBarItem.title = …
也可以这样:
[[UITabBarItem alloc] initWithTitle:image:tag:]
注意:the vc.title 相当于下面这两句
vc.navigationItem.title = …
vc.tabBarItem.title = …
// 设置微章
vc.tabBarItem.badgeValue = @"4";
[item setFinishedSelectedImage:withFinishedUnselectedImage:]; is deprecated.
TabBar:
tintColor
barTintColor
backgroundImage
通过UIAppearance设置item的标题颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor orangeColor]} forState:UIControlStateSelected];
定制item,设置普通图片、选中图片和标题
第一种方式:
vc.tabBarItem.image = …
vc.tabBarItem.selectedImage = … noted the renderingMode of image
vc.tabBarItem.title
上面三句代码对应:
[[UITabBarItem alloc] initWithTitle:image:selectedImage:]
设置选中标题颜色:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor orangeColor]} forState:UIControlStateSelected];
限免
tabbar_limitfree.png
tabbar_limitfree_press.png
降价
tabbar_reduceprice.png
tabbar_reduceprice_press.png
免费
tabbar_appfree
tabbar_appfree_press
专题
tabbar_subject
tabbar_subject_press
热榜
tabbar_rank
tabbar_rank_press
——————————————————————————————
3. 自定制tabBar
思路:
1. 把系统的tabBar隐藏掉
2. 新建imageView,在上面加一个个button 并给button设置图片
3. 当点击其中一个button时触发相应的方法并跳转到对应的控制器.selectedViewController = …

—————————————————————————————
定制TabBarController 2

code4.app
tab_feed.png tab_live tab_feed_profile.png tab_messages.png
给ViewController做扩展
+ (instancetype) viewControllerWithTabTitle:(NSString*)title image:(UIImage*)image selectedImage:(UIImage *)selectedImage
实现中间大按钮的思路:加一个按钮,把这个按钮放在中间位置
CGFloat heightDifference = image.size.height - self.tabBar.frame.size.height;
if (heightDifference < 0)
button.center = self.tabBar.center;
else
{
CGPoint center = self.tabBar.center;
center.y = center.y - heightDifference/2.0;
button.center = center;
}
—————————————————————————————
作业:

UITabBarController
标签控制器
系统tabBarItem
1. UITabBarController
UITabBarItem
代理方法
NSUserDefaults
System item:
UITabBarItem alloc initWithTabBarSystemItem:tag:
We can’t set the title and image if use the systemItem
用系统预置好item无法设置标题和图片
Noted the loadView viewDidLoad and willWillAppear executed only for current controller
.moreNavigationController not in viewControllers
selectedIndex
selectedViewController
delegate方法的使用
NSUserDefault的使用
// 注:住偏好设置里面存的值比较有限,只支持以下几种:
// Array Dictionary BOOL Data Date Number String简单的类型
// [userDefault setBool:(BOOL) forKey:(NSString *)];
// [userDefault boolForKey:(NSString *)]
// [userDefault setInteger:(NSInteger) forKey:(NSString *)];
// [userDefault integerForKey:(NSString *)]
// 往偏好设置中存储Data不推荐用
// 偏好设置使用场景是一些简单的用户操作,设置等,不宜存储大容量和复杂的数据
// 注:往偏好里面基于同一个key赋值会把原来相同key对应的值覆盖掉
——————————————————————————————
2. 定制TabBarController & item
项目爱限免界面搭建

NSArray *commonImgNames = @[@"tabbar_limitfree", @"tabbar_reduceprice", @"tabbar_appfree", @"tabbar_subject", @"tabbar_rank"];
NSArray *titles = @[@"限免", @"降价", @"免费", @"专题", @"热榜"];
设置
vc.tabBarItem.image
// vc.title = @“1512棒棒哒”;
vc.tabBarItem.title = …
也可以这样:
[[UITabBarItem alloc] initWithTitle:image:tag:]
注意:the vc.title 相当于下面这两句
vc.navigationItem.title = …
vc.tabBarItem.title = …
// 设置微章
vc.tabBarItem.badgeValue = @"4";
[item setFinishedSelectedImage:withFinishedUnselectedImage:]; is deprecated.
TabBar:
tintColor
barTintColor
backgroundImage
通过UIAppearance设置item的标题颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor orangeColor]} forState:UIControlStateSelected];
定制item,设置普通图片、选中图片和标题
第一种方式:
vc.tabBarItem.image = …
vc.tabBarItem.selectedImage = … noted the renderingMode of image
vc.tabBarItem.title
上面三句代码对应:
[[UITabBarItem alloc] initWithTitle:image:selectedImage:]
设置选中标题颜色:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor orangeColor]} forState:UIControlStateSelected];
限免
tabbar_limitfree.png
tabbar_limitfree_press.png
降价
tabbar_reduceprice.png
tabbar_reduceprice_press.png
免费
tabbar_appfree
tabbar_appfree_press
专题
tabbar_subject
tabbar_subject_press
热榜
tabbar_rank
tabbar_rank_press
——————————————————————————————
3. 自定制tabBar
思路:
1. 把系统的tabBar隐藏掉
2. 新建imageView,在上面加一个个button 并给button设置图片
3. 当点击其中一个button时触发相应的方法并跳转到对应的控制器.selectedViewController = …

—————————————————————————————
定制TabBarController 2

code4.app
tab_feed.png tab_live tab_feed_profile.png tab_messages.png
给ViewController做扩展
+ (instancetype) viewControllerWithTabTitle:(NSString*)title image:(UIImage*)image selectedImage:(UIImage *)selectedImage
实现中间大按钮的思路:加一个按钮,把这个按钮放在中间位置
CGFloat heightDifference = image.size.height - self.tabBar.frame.size.height;
if (heightDifference < 0)
button.center = self.tabBar.center;
else
{
CGPoint center = self.tabBar.center;
center.y = center.y - heightDifference/2.0;
button.center = center;
}
—————————————————————————————
作业:

0 0
- UI学习
- UI学习
- UI的学习
- UI工厂学习一
- jquery UI学习
- UI控件学习
- Android的UI学习
- Android UI学习 - Menu
- Android UI学习 - ListView
- UI Automation学习
- Android UI学习 - Menu
- Android UI学习 - TableLayout
- Android UI学习 - Menu
- Android UI学习 - ListView
- Android UI学习 - Menu
- Android UI学习 - ListView
- UI学习(一)
- jquery UI 学习
- spring框架整合使用定时任务框架java quartz的示例代码配置
- MyBatis动态传入表名,字段名参数的解决办法
- Html5入门第二篇-初识css
- 谈谈面试与面试题
- bbs
- UI学习
- Spring动态对Quartz定时任务的管理,实现动态加载,停止的配置实例代码
- Oracle TO_CHAR()和TO_DATA()函数日期和字符串互相转换
- Graphviz 和 pygraphviz 简述、安装、用法
- CentOS下安装Hadoop单机版
- 谈一谈网络编程学习经验(06-08更新)
- java定时任务类Timer和TimerTask用法详解
- Hadoop单节点集群安装(伪分布式安装)
- Spring定时器配置的两种实现方式OpenSymphony Quartz和java Timer详解