TabBarController的使用
来源:互联网 发布:ip归属地数据库 离线 编辑:程序博客网 时间:2024/06/09 23:40
TabBarController的使用
凡是加入的标签控制器的视图控制器都有tabBarItem和tabBarController两个属性
什么时候使用系统自带的tabBarController中的TabBar?
1.项目没有什么特别需求
2.美工能够给到30*30的镂空图片
如何使用系统自带的tabBarController?
1.点击StoryBoard,拖一个UITabBarController,并将其设置为初始化视图控制器
2.根据项目需求设置viewControllers
3.设置tabBar
1>点击相对应的tabItem,根据需求设置title和image
凡是加入的标签控制器的视图控制器都有tabBarItem和tabBarController两个属性 可以到对应的视图控制器中设置tabBarItem
自定义tabBarItem 当tabBar有嵌入导航控制器时需要通过navigationController作为属性媒介
//将系统的tabBar覆盖 view = [[UIView alloc]initWithFrame:self.tabBar.bounds]; view.backgroundColor = [UIColor whiteColor]; [self.tabBar addSubview:view]; for (int i = 0; i<4; i++) { //从IB载入自定义的TabBarItem(view) CustonTabBarItem *item = [[[NSBundle mainBundle]loadNibNamed:@"CustonTabBarItem" owner:self options:nil] lastObject]; item.frame = CGRectMake(0+i*self.view.frame.size.width/4, 0, self.view.frame.size.width/4, 44); if (i==1) { [item.imageButton setImage:[UIImage imageNamed:@"demo1.jpg"] forState:0]; [item.imageButton addTarget:self action:@selector(publishAction:) forControlEvents:UIControlEventTouchUpInside]; }else{ //选中状态与非选中状态的照片 [item.imageButton setImage:[UIImage imageNamed:@"demo.jpg"] forState:0]; [item.imageButton setImage:[UIImage imageNamed:@"demo2.jpg"] forState:UIControlStateSelected]; [item.imageButton addTarget:self action:@selector(changeIndex:) forControlEvents:UIControlEventTouchUpInside]; } //设置标记,判断点击的button item.imageButton.tag = 100+i; item.badgeLabel.text=@"3"; if (i==0) { item.imageButton.selected = YES; tempButton = item.imageButton; } [view addSubview:item]; }-(void)publishAction:(UIButton *)sender{ [self presentViewController:[ViewController new] animated:YES completion:^{ }];}//选中状态与非选中状态的处理-(void)changeIndex:(UIButton *)sender{ //方法一// for (CustonTabBarItem *ele in view.subviews) {// ele.imageButton.selected = NO;// }// sender.selected = YES; //方法二 可判断双击 if (sender.tag == tempButton.tag) { //同一个item 连续点击两下 NSLog(@"点击两下"); return; } tempButton.selected = NO; sender.selected = YES; tempButton = sender; if (sender.tag >101) { self.selectedIndex = sender.tag - 101; }else self.selectedIndex = sender.tag -100;}
0 0
- TabBarController的使用
- tabbarController的使用
- 使用tabbarcontroller
- Swift开发之 使用系统的TabbarController
- 【swift】使用tabbarController出现的问题
- 使用TabBarController 多视图
- TabBarController与NavigationController结合使用时的隐藏问题
- tabBarController 的隐藏问题
- TabbarController的封装
- TabBarController
- TabBarController
- tabBarController
- TabBarController
- tabbarController
- TabBarController
- TabBarController
- tabBarController的外观的设置
- iOS 会跳舞的TabbarController
- 04环信聊天界面 - 完善聊天输入框
- HDU5573 Binary Tree
- 第2章{ 2-10 使用依赖表控制combo }
- 如何有效地记忆与学习
- MmProbeAndLockPages routine
- TabBarController的使用
- ssdb学习
- 枚举导致的WCF Web Service接口返回异常
- 第2章{ 2-11 kissy的调试模式 }
- 第2章{ 2-12 使用gulp构建kissy工程 }
- oracle之算术运算符
- CocoaPods的安装使用和常见问题
- 问题“undefined reference to `android_log_print”的解决办法
- 第2章{ 2-13 使用抓包工具线上调试 }