【发布时间】:2012-12-29 04:18:31
【问题描述】:
我对导航栏进行了更改意味着我增加了导航栏的高度并进行了一些自定义更改,它工作正常但是当我最小化应用程序并再次最大化它时,它只显示原始高度,这就是我所做的更改,那些在最小化后不起作用,我的代码是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@" i m in didFinishLaunchingWithOptions" );
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"TopHeader"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setFrame:CGRectMake(0, 0, 320, 55)];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:(-15.0) forBarMetrics:UIBarMetricsDefault];
[[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.8],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:16.0], UITextAttributeFont, nil]];
return YES;
}
最大化后它转到applicationDidBecomeActive 这就是为什么我将上面的代码放在applicationDidBecomeActive 但它不起作用,为什么会这样?
最小化之前
再次最小化和最大化后,它看起来像下面,即高度再次自动设置为 44。
更新:我在applicationWillEnterForeground 中编写了以下代码
- (void)applicationWillEnterForeground:(UIApplication *)application
{
UINavigationController *my=(UINavigationController * )self.window.rootViewController;
UINavigationBar *navigationBar = [my navigationBar];
CGRect frame = [navigationBar frame];
frame.size.height = 55.0f;
[navigationBar setFrame:frame];
NSLog(@" i m in applicationWillEnterForeground" );
}
在调试时,当我编写它的描述时,它显示高度为 55。但在屏幕上它看起来仍然像第二张图像。为什么会这样。
【问题讨论】:
-
反对者请发表评论?不必要地投票不是一件好事
标签: iphone ios uinavigationbar lifecycle