【发布时间】:2013-04-30 16:37:23
【问题描述】:
典型的 NavController 行为是在端口/风景中调整大小。从 44px 高度到 32px 我相信(从我的头顶)。
我正在使用故事板并将导航栏包含在 VC 中,而不是控制器中。在纵向和横向之间旋转时,导航栏不会自动调整大小。
我已经看到了这个答案,但这并没有帮助:Resizing UINavigationBar on rotation
导航栏是通过外观加载在 App Delegate 中的控制器:
UIImage *portraitImage = [UIImage imageNamed:@"mainNavBar"];
UIImage *landscapeImage = [UIImage imageNamed:@"mainNavBarLandscape"];
[[UINavigationBar appearance] setBackgroundImage:portraitImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:landscapeImage forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,nil]];
[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin];
不幸的是,最后一部分没有任何区别,由于导航栏将包含在多个控制器中,我不想在上面的问题中重复相同的胶水代码,以调整我所有 VC 的旋转大小。
【问题讨论】:
标签: ios ios5 uinavigationcontroller uinavigationbar uinavigationitem