0
希望第三次幸运:的TabBar和导航栏视图部分地隐藏
只是试图获取内容出现下面导航栏和上面的标签栏(有没有它,下面会出现两种)。
我已经尝试几乎所有的东西,无济于事。
随着内rootController了下面的代码,我只是想有一个视图(红色边框,以帮助显示,如果它的工作):
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
UIView *view1 = [[UIView alloc] initWithFrame:self.view.frame];
view1.layer.borderColor = [UIColor redColor].CGColor;
view1.layer.borderWidth = 2.0f;
[self.view addSubview:view1];
}
和设置为幸福:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
TSTFirstViewController *rootController = [[TSTFirstViewController alloc] init];
rootController.title = @"Hello World";
UINavigationController *firstRootController = [[UINavigationController alloc] initWithRootViewController:rootController];
NSArray *viewControllers = @[firstRootController];
UITabBarController *tabBar = [[UITabBarController alloc] init];
tabBar.viewControllers = viewControllers;
tabBar.tabBar.barStyle = UIBarStyleBlack;
tabBar.tabBar.translucent = NO;
[self.window setRootViewController:tabBar];
[self.window makeKeyAndVisible];
return YES;
}
我得到:
如果我添加两个行我AppDelegate
:
firstRootController.navigationBar.translucent = NO;
firstRootController.navigationBar.barStyle = UIBarStyleBlack;
这一切都变得非常混乱:
的红色边框下移,底部边框消失的标签栏下方。并出现一个大的空白。
如果我删除了半透明线,并添加:
self.edgesForExtendedLayout = UIRectEdgeNone;
到视图控制器,我得到:
半透明的酒吧,在正确的位置红色边框导航栏下,但tabBar下方的下边框。
我相信我已经尝试过所有的组合和所有的想法。
任何人都可以请告诉我如何让内容适合在导航栏下面,在标签栏之上而不使用Interface Builder。
在此先感谢。
非常感谢您的帮助......但我不禁想知道是否有比这更容易的东西?我会认为使用'self.edgesForExtendedLayout'可以使视图适合,而不必计算所有单个组件的高度。 – Darren