No.06 Xcode(5.1.x) UINavigationController
来源:互联网 发布:买家怎么进淘宝试衣间 编辑:程序博客网 时间:2024/06/05 21:13
1.在iOS7.0以上版本中, 如果UINavigationController作为UIWindow的根控制器, 顶部的导航栏会包含状态栏, 并且UINavigationController包含的子视图默认左上角与状态栏左上角对齐, 需要将translucent设置为NO才正常.
2.加入的子控制器, 都包含在childViewControllers属性中, 可以作为只读属性来查, 但是最好不要去更改它, 请用UINavigationController的接口去更改子视图
3.navigationBar是顶部的导航栏, 但是如果想要通过navigationBar.frame来获取导航栏的区域, 是不可行的, 通常使用硬编码来获取这个值:
- 纵向模式为44像素;
- 横向模式为32像素;
- 提示模式为74像素(横向和纵向);
4.导航栏的左右键定制时, 建议使用[initWithCustomView:]方法, [initWithBarButtonSystemItem: target: action:]等方法难以定制按钮的外形
5.使用[pushViewController: animated:]等方法弹出或加入视图时, 可以将animated参数设置为NO, 然后在navigationController.view.layer上建立自定义动画
创建导航栏
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ ViewController* controller = [[ViewController alloc] init]; UINavigationController* naviController = [[UINavigationController alloc] initWithRootViewController:controller]; naviController.navigationBar.translucent = YES; naviController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], NSForegroundColorAttributeName, [UIFont systemFontOfSize:20.0], NSFontAttributeName, nil]; // 设置字体 [naviController.navigationBar setBackgroundImage:[UIImage imageNamed:@"Ingredients/bg003.png"] forBarMetrics:UIBarMetricsDefault]; // 设置背景 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = naviController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES;}
定制导航栏
- (void)viewDidLoad{ [super viewDidLoad]; // 定制右键 UIButton* rtButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 80.0, 20.0)]; [rtButton setBackgroundColor:[UIColor grayColor]]; [rtButton setTitle:@"普通" forState:UIControlStateNormal]; [rtButton setTitle:@"高亮" forState:UIControlStateHighlighted]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rtButton];}
加入或弹出
- (void)popToPrev:(UIButton*)button{ CATransition* transition = [CATransition animation]; transition.duration = 1.0; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = @"cube"; transition.subtype = kCATransitionFromLeft; transition.delegate = self; [self.navigationController.view.layer addAnimation:transition forKey:@"animationxxxx"]; [self.navigationController popViewControllerAnimated:NO];}- (void)popToSome:(UIButton*)button{ UIViewController* controller = [self.navigationController.childViewControllers objectAtIndex:0]; [self.navigationController popToViewController:controller animated:YES];}- (void)popToRoof:(UIButton*)button{ [self.navigationController popToRootViewControllerAnimated:YES];}
0 0
- No.06 Xcode(5.1.x) UINavigationController
- No.08 Xcode(5.1.x) 使用FFmpeg
- No.10 Xcode(5.1.x) UITabBarController
- No.14 Xcode(5.1.x) socket
- No.15 Xcode(5.1.x) libxml2
- No.03 Xcode(5.1.x) c,c++,objiective-c混编
- No.05 Xcode(5.1.x) 服务器消息推送
- No.11 Xcode(5.1.x) 设备或程序旋转
- No.12 Xcode(5.1.x) NSString, NSArray 和 NSDictionary
- No.13 Xcode(5.1.x) 获取设备信息, 系统信息
- No.07 Xcode(5.x) 使用SQLite
- No.09 Xcode(5.x) UITextField
- No.01 Xcode(7.x) 键盘
- No.04 Xcode(7.x) GCD相关
- No.04 Xcode(7.x) 蓝牙
- No.01 Xcode(5.1.x) 在Vmware中安装Mac OS X 10.8
- No.04 Xcode(5.x) app的测试与发布
- No.02 Xcode(7.x) 横竖屏旋转
- 平时学习积累
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- bind双网卡
- Linux进程间通信-基于内存(共享队列)
- ERROR: invalid page header in block 13760 of relation base/16995/67484
- No.06 Xcode(5.1.x) UINavigationController
- Android初级教程_保留listview item的选中样式
- Android下获取各种存储目录
- UUID/UDID/
- grep in Windows
- C++大学基础教程_11_10_实例研究:String类
- UVA 10561 - Treblecross(博弈SG函数)
- 启动tomcat报错 java.lang.Exception: Socket bind failed
- 使用JMX监控Tomcat