7.0以下系统:
1.有nav的时候,并且self.navigationController.navigationBar.translucent = YES; navBar为半透明状态,在viewDidAppear中self.view.fream:
2014-04-23 16:26:58.416 Ani[27883:907] viewDidAppear <UIView: 0x1cdaf070; frame = (0 0; 320 460); autoresize = W+H; layer = <CALayer: 0x1cdae6a0>>
2014-04-23 16:26:58.425 Ani[27883:907] viewDidAppear <UIViewControllerWrapperView: 0x1cdc3fa0; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x1cdc4050>>
2014-04-23 16:26:58.450 Ani[27883:907] viewDidAppear <UINavigationTransitionView: 0x1cdaa7f0; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1cdaa8c0>>
2014-04-23 16:26:58.457 Ani[27883:907] viewDidAppear <UILayoutContainerView: 0x1cda7e20; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x1cda7ee0>>
2014-04-23 16:26:58.462 Ani[27883:907] viewDidAppear <UIWindow: 0x1cda6c90; frame = (0 0; 320 480); autoresize = W+H; layer = <UIWindowLayer: 0x1cda6d60>>
navBar不透明状态时候:
2014-04-23 16:37:42.471 Ani[27905:907] viewDidAppear <UIView: 0x1d56dac0; frame = (0 0; 320 416); autoresize = W+H; layer = <CALayer: 0x1d56d0f0>>
2014-04-23 16:37:42.485 Ani[27905:907] viewDidAppear <UIViewControllerWrapperView: 0x1d582860; frame = (0 64; 320 416); autoresize = W+H; layer = <CALayer: 0x1d582910>>
2014-04-23 16:37:42.491 Ani[27905:907] viewDidAppear <UINavigationTransitionView: 0x1d569240; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1d569310>>
2014-04-23 16:37:42.501 Ani[27905:907] viewDidAppear <UILayoutContainerView: 0x1d566850; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x1d566910>>
2014-04-23 16:37:42.506 Ani[27905:907] viewDidAppear <UIWindow: 0x1d5656e0; frame = (0 0; 320 480); autoresize = W+H; layer = <UIWindowLayer: 0x1d5657b0>>
2.没有navBar的时候。
2014-04-23 16:39:49.619 Ani[27924:907] viewDidAppear <UIView: 0x1fd49b30; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x1fd490c0>>
2014-04-23 16:39:49.628 Ani[27924:907] viewDidAppear <UIWindow: 0x1fd46960; frame = (0 0; 320 480); autoresize = W+H; layer = <UIWindowLayer: 0x1fd46a30>>
7.0以上系统:
1.有nav的时候,并且self.navigationController.navigationBar.translucent = YES; navBar为半透明状态,在viewDidAppear中self.view.fream:
2014-04-23 16:43:47.970 Ani[5298:60b] viewDidAppear <UIView: 0x1665b990; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x1665ae50>>
2014-04-23 16:43:47.973 Ani[5298:60b] viewDidAppear <UIViewControllerWrapperView: 0x1666ae40; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x1666af30>>
2014-04-23 16:43:47.975 Ani[5298:60b] viewDidAppear <UINavigationTransitionView: 0x16537f90; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x165679a0>>
2014-04-23 16:43:47.976 Ani[5298:60b] viewDidAppear <UILayoutContainerView: 0x1658d100; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x16656530>; layer = <CALayer: 0x1658d250>>
2014-04-23 16:43:47.978 Ani[5298:60b] viewDidAppear <UIWindow: 0x1658b8a0; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x1658bd50>; layer = <UIWindowLayer: 0x1658b9d0>>
navBar不透明状态时候:
2014-04-23 16:46:21.853 Ani[5313:60b] viewDidAppear <UIView: 0x16da18b0; frame = (0 64; 320 504); autoresize = W+H; layer = <CALayer: 0x16da0d70>>2014-04-23 16:46:21.856 Ani[5313:60b] viewDidAppear <UIViewControllerWrapperView: 0x16da74b0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x16da75a0>>
2014-04-23 16:46:21.858 Ani[5313:60b] viewDidAppear <UINavigationTransitionView: 0x16d77790; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x16d8fec0>>
2014-04-23 16:46:21.860 Ani[5313:60b] viewDidAppear <UILayoutContainerView: 0x16d98fe0; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x16d9cd70>; layer = <CALayer: 0x16d99130>>
2014-04-23 16:46:21.861 Ani[5313:60b] viewDidAppear <UIWindow: 0x16d985f0; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x16d98aa0>; layer = <UIWindowLayer: 0x16d98720>>
2.没有navBar的时候。
2014-04-23 16:48:14.834 Ani[5320:60b] viewDidAppear <UIView: 0x17da7120; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x17da6540>>2014-04-23 16:48:14.837 Ani[5320:60b] viewDidAppear <UIWindow: 0x17da48f0; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x17da5db0>; layer = <UIWindowLayer: 0x17da4880>>
/
iOS7以上系统,self.navigationController.navigationBar.translucent默认为YES,self.view.frame.origin.y从0开始(屏幕最上部)。
此时若是添加代码self.edgesForExtendedLayout = UIRectEdgeNone(iOS7.0以后方法);self.view.frame.origin.y会下移64像素至navBar下方开始。但是此时当push到一个新的controller之前给当前屏幕截图的时候[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];,由于navBar是透明的,会出现64像素的黑色区域。
此时只需要把self.navigationController.navigationBar.translucent=NO即可,不需要加代码self.edgesForExtendedLayout;
iOS7之后也增加了一个self.tabBarController.tabBar.translucent的属性,默认为YES。当应用同时使用navBar和TabBar的时候。设置self.tabBarController.tabBar.translucent=NO并且self.navigationController.navigationBar.translucent=NO时候,得到self.view.frame--->{{0, 64}, {320, 455}}。视图的高度也改变为navBar和tabBar之间的455像素。当self.navigationController.navigationBar.translucent=YES并且self.tabBarController.tabBar.translucent=NO的时候self.view.frame--->{{0, 0}, {320, 519}};其都为YES的时候self.view.frame--->{{0, 0}, {320, 568}};
注意:设置self.edgesForExtendedLayout = UIRectEdgeNone;的时候会使得navBar和tabBar都不占空间。self.view.frame--->{{0, 64}, {320, 455}}。此时iOS7默认navBar和tabBar都是透明的。截图的时候需要注意。
iOS6以下系统,默认navBar和tabBar都不占空间。