ナビゲーションバーに変更を加えたということは、ナビゲーションバーの高さを増やしてカスタム変更を加えたことを意味します。これは正常に機能しますが、アプリケーションを最小化して再度最大化すると、元の高さのみが表示されます。最小化後に動作します、私のコードは
- (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であることが示されていますが、画面上では2番目の画像のように見えます。なぜこれが起こっているのか。