question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Title is not vertically centered in <Navigator.NavigationBar> when using custom height

See original GitHub issue

When using custom height of 50, this is what I get for <Navigator.NavigationBar style={{height: 50}}> (as you can see it’s not vertically centered):

normal

When using a negative marginTop to adjust both the back button and the title, it cuts off the top of the back button:

negative-margin

What’s the proper way to fix this (preferably without negative margin)?

RN 0.30 / Mac OS X 10.11.5 / iPhone 6 / iOS 9.3

P.S: I could only find this other issue, but it’s not too helpful: https://github.com/facebook/react-native/issues/3142

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ifourscommented, Aug 16, 2016

You can try following workaround (you still need to use negative margin):

const navigationStyles = { ...Navigator.NavigationBar.StylesIOS };

navigationStyles.Stages.Left.LeftButton.overflow = 'visible';
navigationStyles.Stages.Center.LeftButton.overflow = 'visible';
navigationStyles.Stages.Right.LeftButton.overflow = 'visible';

navigationStyles.Stages.Left.RightButton.overflow = 'visible';
navigationStyles.Stages.Center.RightButton.overflow = 'visible';
navigationStyles.Stages.Right.RightButton.overflow = 'visible';

And pass as prop to your NavigationBar

0reactions
facebook-github-botcommented, Nov 14, 2016

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my react native navigation bar's text not on the vertical ...
I just ran into this issue too. The solution: <Navigator.NavigationBar routeMapper={{ Title: (route, navigator, index, navState) => { return ...
Read more >
iOS 16 Beta Vertically Aligns Navi… | Apple Developer Forums
On iOS 16, I noticed that the navigation bar title view is being aligned vertically to the top, I cannot figure out why....
Read more >
How to Vertically Center Text with CSS - W3Docs
To position text vertically positioned with CSS you can use vertical-align, line-height, transform properties, flexbox. Learn more methods. Try examples.
Read more >
Navbar | Webflow University
The height of the navbar is determined by the content inside — either the height of the brand logo or the height of...
Read more >
Styling your Navigation - Adobe Portfolio
Set a Navigation height (this will also determine the height of your logo); Vertically Align your navigation elements (Page titles, social icons ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found