【iOS开发-78】用代码实现UITabBarController+UINavigationController
来源:互联网 发布:数据结构与算法 云盘 编辑:程序博客网 时间:2024/05/23 19:39
#import "WPTabBarController.h"#import "WPFirstViewController.h"#import "WPSecondViewController.h"#import "WPThirdViewController.h"#import "WPFourthViewController.h"@interface WPTabBarController ()@end@implementation WPTabBarController- (void)viewDidLoad { WPFirstViewController *firsVc=[[WPFirstViewController alloc]init]; WPSecondViewController *secondVc=[[WPSecondViewController alloc]init]; WPThirdViewController *thirdVc=[[WPThirdViewController alloc]init]; WPFourthViewController *fourthVc=[[WPFourthViewController alloc]init]; //以下两种方式均可设置tabbar上得标题 firsVc.tabBarItem.title=@"消息"; //firsVc.title=@"消息"; secondVc.tabBarItem.title=@"联系人"; //secondVc.title=@"联系人"; thirdVc.tabBarItem.title=@"动态"; //thirdVc.title=@"动态"; fourthVc.tabBarItem.title=@"设置"; //fourthVc.title=@"设置"; //设置icon firsVc.tabBarItem.image=[UIImage imageNamed:@"tab_recent_nor"]; secondVc.tabBarItem.image=[UIImage imageNamed:@"tab_buddy_nor"]; thirdVc.tabBarItem.image=[UIImage imageNamed:@"tab_qworld_nor"]; fourthVc.tabBarItem.image=[UIImage imageNamed:@"tab_me_nor"]; firsVc.view.backgroundColor=[UIColor redColor]; secondVc.view.backgroundColor=[UIColor whiteColor]; thirdVc.view.backgroundColor=[UIColor purpleColor]; fourthVc.view.backgroundColor=[UIColor greenColor]; //用以下方式添加子控制器 //self.viewControllers=@[firsVc,secondVc,thirdVc,fourthVc]; [self addChildViewController:firsVc]; [self addChildViewController:secondVc]; [self addChildViewController:thirdVc]; [self addChildViewController:fourthVc]; [super viewDidLoad]; // Do any additional setup after loading the view.}
核心:
——定义1个tabBat控制器和4个导航控制器,然后通过addChildViewController或者数组的形式把4个导航控制器加到tabBar控制器中。
——每个导航控制器通过tabBarItem属性来设置标题和icon等。
界面截屏:
0 0
- 【iOS开发-78】用代码实现UITabBarController+UINavigationController
- 【iOS开发-77】用storyboard实现主流框架:UITabBarController+UINavigationController
- [IOS]代码创建UINavigationController+UITabBarController
- 代码实现UITabBarController加载UINavigationController
- iOS APP开发整理--UITabBarController,UINavigationController
- 【iOS开发-UITabBarController】UITabBarController上面的UINavigationController的设置
- iOS开发——纯代码界面(UITabBarController,UINavigationController,UIImageView)
- UITabBarController UINavigationController 相结合代码
- UITabBarController UINavigationController 相结合代码
- UITabBarController UINavigationController 相结合代码
- iOS UINavigationController + UITabBarController
- 纯代码搭建iOS三级结构(UITabbarController+UINavigationController+UIViewController)
- iOS开发 代码创建UITabBarController
- 【深入浅出IOS开发】UITabBarController和UINavigationController混合使用
- 【深入浅出IOS开发】UITabBarController和UINavigationController混合使用
- iOS 自定义UINavigationController和UITabBarController
- IOS学习笔记(5)UINavigationController UITabBarController
- IOS学习笔记(5)UINavigationController UITabBarController
- STM32 JTAG的引脚用作GPIO引脚
- Framework层添加一个公共资源apk,可供应用调用
- QT 简单的I/O操作
- EJS 模板快速入门
- 【HTML5&CSS3进阶04】CSS3动画应该如何在webapp中运用
- 【iOS开发-78】用代码实现UITabBarController+UINavigationController
- 大端序和小端序
- Windows Linux代码中杀掉进程
- IOS开发之__bridge,__bridge_transfer和__bridge_retained
- Android.mk文件的解释
- Linux笔记 9 (进程管理)
- Node Connect 及其中间件的理念相当好
- 深入理解C语言中的移位运算
- PHP $_SERVER详解