object-ocUI之导航控件
2015-11-24 13:18
573 查看
1.删除系统自己给我们的main.board。和viewCollorer.h/.m文件 ,info.plist删除main
2.appDelegate.m
//手动创建window
self.window =
[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor =
[UIColor whiteColor];
//创建导航控制器
UINavigationController *naviga = [[UINavigationController alloc]initWithRootViewController:[[MYViewController alloc]init]];
//设置下面导航条图片
naviga.tabBarItem.image =
[UIImage imageNamed:@"tab1.png"];
//创建标签控制器(width:49)
UITabBarController *MytabBar = [[UITabBarController alloc]init];
//添加到MytabBar
MytabBar.viewControllers = @[naviga,twoNavi,threeNavi];
//为了让他能启动加载这个window
[self.window makeKeyAndVisible];
3.创建导航右边和左边的按钮
首先定义按钮(系统自定义)
//创建右边按钮
UIBarButtonItem *btnGO = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(ClickedItem:)];
//自定义按钮用自定义按钮方法
UIBarButtonItem *btnUP = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(ClickedItem:)];
//自定义设置导航默认的返回按钮
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:nil];
//改变图片返回按钮
[self.navigationController.navigationBar setBackIndicatorImage:[UIImage imageNamed:@"back_btn.png"]];
[self.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn.png"]];
//自动以颜色按钮
[self.navigationController.navigationBar setTintColor:[UIColor purpleColor]];
//设置导航条按钮
[self.navigationController.navigationBar setBarTintColor:[UIColor orangeColor]];
//设置字体大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25],NSForegroundColorAttributeName:[UIColor blueColor]}];
4.使用导航页面跳转
SecondViewController *twoView = [[SecondViewController alloc]init];
//页面跳转
[self.navigationController pushViewController:twoView animated:YES];
5.页面回跳
//返回到最主页,弹出当前控制器,或者跳到指定页面
[self.navigationController popToRootViewControllerAnimated:YES];
2.appDelegate.m
//手动创建window
self.window =
[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor =
[UIColor whiteColor];
//创建导航控制器
UINavigationController *naviga = [[UINavigationController alloc]initWithRootViewController:[[MYViewController alloc]init]];
//设置下面导航条图片
naviga.tabBarItem.image =
[UIImage imageNamed:@"tab1.png"];
//创建标签控制器(width:49)
UITabBarController *MytabBar = [[UITabBarController alloc]init];
//添加到MytabBar
MytabBar.viewControllers = @[naviga,twoNavi,threeNavi];
//为了让他能启动加载这个window
[self.window makeKeyAndVisible];
3.创建导航右边和左边的按钮
首先定义按钮(系统自定义)
//创建右边按钮
UIBarButtonItem *btnGO = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(ClickedItem:)];
//自定义按钮用自定义按钮方法
UIBarButtonItem *btnUP = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(ClickedItem:)];
//自定义设置导航默认的返回按钮
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:nil];
//改变图片返回按钮
[self.navigationController.navigationBar setBackIndicatorImage:[UIImage imageNamed:@"back_btn.png"]];
[self.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn.png"]];
//自动以颜色按钮
[self.navigationController.navigationBar setTintColor:[UIColor purpleColor]];
//设置导航条按钮
[self.navigationController.navigationBar setBarTintColor:[UIColor orangeColor]];
//设置字体大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25],NSForegroundColorAttributeName:[UIColor blueColor]}];
4.使用导航页面跳转
SecondViewController *twoView = [[SecondViewController alloc]init];
//页面跳转
[self.navigationController pushViewController:twoView animated:YES];
5.页面回跳
//返回到最主页,弹出当前控制器,或者跳到指定页面
[self.navigationController popToRootViewControllerAnimated:YES];
相关文章推荐
- flex 控件的重要属性
- Delphi控件ListView的属性及使用方法详解
- web下载的ActiveX控件自动更新
- WinForm实现按名称递归查找控件的方法
- C#中父窗口和子窗口之间控件互操作实例
- jQuery实现下滑菜单导航效果代码
- jquery实现的仿天猫侧导航tab切换效果
- Android编程之Button控件用法实例分析
- Android控件之CheckBox、RadioButton用法实例分析
- MFC中动态创建控件以及事件响应实现方法
- WinForm自定义函数FindControl实现按名称查找控件
- Android控件之ProgressBar用法实例分析
- PHP的栏目导航程序
- WinForm拖拽控件生成副本的解决方法
- jquery实现向下滑出的二级导航下滑菜单效果
- ASP.NET动态添加用户控件的方法
- ASP.NET的HtmlForm控件学习及Post与Get的区别概述
- JS+CSS实现六级网站导航主菜单效果
- WinForm实现移除控件某个事件的方法
- JS实现网页顶部向下滑出的全国城市切换导航效果