i have made changes in navigation bar means i have increasd the height of navigation bar & made some custom changes,it works fine but when i minimizes the application and again maximize it, it shows only original height that is what changes i made, those not works after minimization, my code is
- (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;
}
after maximize it goes to applicationDidBecomeActive
thats why i put above code in applicationDidBecomeActive
but its not working, why this is happening?
before minimize
after minimize & maximize again it looks like below i.e. height again automatically sets to 44.
Update: i written following code in 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" );
}
at the time of debugging when i writes its description it shows that height is 55. but on screen it still looks like second image. why this is happening.
When your app opens from the background
application:didFinishLaunchingWithOptions:
does not get called. You want to use eitherapplicationWillEnterForeground:
orapplicationDidBecomeActive:
instead. Check out theUIApplicationDelegate
protocol reference for more information.EDIT: In response to the question author's edits, I will say this. I played around with this code in an app of mine, and I've been able to reproduce the problem. I've tried a number of solutions to fix it, including resetting the frame of the navbar in a
UINavigationController
'slayoutSubviews
. I suggest creating a sample project that reproduces this issue and submitting it to Apple's Bug reporter, or creating a UINavigationBar subclass that repositions and resizes itself.I solved this problem, just overrides the UINavigationBar & in LayoutSubViews set the height of navigationBar.
that means whenever i draws the navigationBar it calls automatically & sets the height.