UI - NavigationController
2015-12-26 14:40
387 查看
/************************************* 导航栏的定制 *************************************/ self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; //设置导航控制器: //1.创建一个根视图控制器 ViewController *vc = [[ViewController alloc]init]; //2.vc作为导航控制器的根视图控制器 UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc]; //3.导航控制器是window的根视图控制器 self.window.rootViewController = navi; navi.view.backgroundColor = [UIColor whiteColor]; /************************************* 导航控制器推出视图 *************************************/ SecondViewController *svc = [[SecondViewController alloc]init]; // 采用出栈入栈的方式推出下个页面 push pop 先进(栈底)后出(栈顶) //1.进入下一个视图控制器 [self.navigationController pushViewController:svc animated:YES]; //2.返回上一个视图控制器 [self.navigationController popToRootViewControllerAnimated:YES]; //3.返回指定的视图控制器 [self.navigationController popToViewController:svc animated:YES]; //4.返回到根视图控制器 [self.navigationController popToRootViewControllerAnimated:YES]; //常用属性 //1.所有处于栈中的控制器 self.navigationController.viewControllers; //2.位于栈顶的控制器 self.navigationController.topViewController; //3.当前正在显示的控制器 self.navigationController.visibleViewController; //4.导航条 self.navigationController.navigationBar; /************************************* 导航控制器的创建 *************************************/ // 一、对导航栏的定制: 影响每个子视图 // self.navigationController.navigationBar //(1)半透明效果(默认打开, 若关闭, 左边原点会在导航栏的左下方, 整个屏幕下移) self.navigationController.navigationBar.translucent = YES; //调整: 状态栏20 导航栏44(横屏 32) //(2)背景颜色(最上层导航栏) self.navigationController.navigationBar.barTintColor = [UIColor yellowColor]; //(最下层导航栏) self.navigationController.navigationBar.backgroundColor = [UIColor blackColor]; //(3)添加导航栏的背景图片, 半透明效果自动关闭 [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"2.jpg"] forBarMetrics:UIBarMetricsDefault]; // 二、设置当前控制器显示在导航栏上的信息 // self.navigationController.navigationItem //(1)设置标题 //1.第一种方式:推荐 self.navigationItem.title = @"第一页"; //2.第二种方式: 会影响其他的东西 // self.title = @"首页"; //(2)自定义标题视图 self.navigationItem.titleView = [[UISegmentedControl alloc]initWithItems:@[@"消息", @"电话"]]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(leftBarButtonAction:)]; // self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"变色" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction:)]; //使用矢量图: 百度阿里巴巴矢量图 // imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal(取消渲染) self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"4.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction:)]; //渲染颜色设置 self.navigationController.navigationBar.tintColor = [UIColor blackColor];
相关文章推荐
- LeetCode(115) Distinct Subsequences
- LeetCode(115) Distinct Subsequences
- ios 仿新浪微博 UINavigationController 向左滑动时显示上一个控制器的View.
- require.js 配置文件研究
- OSGI blueprint Converter的使用
- CSS marquee滚动 长宽怎么设置代码
- . ERROR! The server quit without updating PID file
- Core BlueTooth官方文档翻译
- Xcode7.2核心动画Layer的简单认识使用
- 给 TI BLE 添加自己UUID
- UI - UITableView表视图 ( 一 )
- BNU OJ 51003 BQG's Confusing Sequence
- Android UI设计: 分享一个仿QQ聊天消息提示可以拖拉气泡
- Qt基础——让使用Designer创建的UI也能自动适应窗口大小
- UITextField 常用属性及方法
- UIImagePickerController换头像
- 如何解决easyui自定义标签 datagrid edit combobox 手动输入保存不上
- [Falcor] Building Paths Programmatically
- 对于querystring取值时候发生+号变空格的问题
- Leetcode-300.Longest Increasing Subsequence