1

I'm having this problem with i couldn't find an answer for it in the past couple of days.

The navigation bar is not showing to the top edge of the iPhone X in iOS 11 simulator, Is that a simulator bug or i'm doing something wrong ?

Height 88

Screen Shot1

Height 145

Screen Shot2

No background image

Screen Shot3

And this is my code in appdelegate

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
UIImage *navImage = [[UIImage imageNamed:@"iPhone-Navigationbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UINavigationBar appearance] setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault];
IQaid
  • 23
  • 5

1 Answers1

0

Strange behavior, a couple of ideas:

  • Have you tried removing the background image?
  • What size background image has? On iPhone X navigation bar is higher (145pt).
Shebuka
  • 3,148
  • 1
  • 26
  • 43
  • Did try removing all backgrounds and still the same problem, The height for the navigation bar image is 88px, 264@3x , and the background image for the view in 812px – IQaid Nov 06 '17 at 09:25
  • On iPhone X the navigation bar is 145pt. – Shebuka Nov 06 '17 at 09:32
  • @IQaid post a screenshot with setBackgroundImage commented. I expect to see a system grey navigation bar. If not you are still editing it in some other place. – Shebuka Nov 06 '17 at 09:34
  • I edited my question with more screen shots @Shebuka – IQaid Nov 06 '17 at 09:38
  • @IQaid This means that you have a misplaced window or root view. Check your constraints. – Shebuka Nov 06 '17 at 09:40
  • Thank you it worked, `UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 20)];` , changed the 20 to 0 and fixed the problem. Thank you again :) – IQaid Nov 06 '17 at 09:42