我已經在導航欄上的更改意味着我有increasd導航欄&的高度做了一些自定義更改,它工作正常,但是當我最小化應用程序並再次最大化,這表明只有原來的高度是最小化後,我做了什麼變化,那些沒有工作,我的代碼是應用程序生命週期問題
- (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.但在屏幕上它仍然看起來像第二個圖像。爲什麼發生這種情況。
Downvoter plz care care to comment?不必要地downvoting不是一件好事 –