How to hide React Native NavigationBar

后端 未结 11 1749
情书的邮戳
情书的邮戳 2020-12-30 02:25

I have NavigatorIOS under Navigator and would like to hide Navigator\'s NavigationBar to use NavigatorIOS\'s bar. Is there any way to do this?

This is screenshot tha

11条回答
  •  北海茫月
    2020-12-30 02:33

    I solved this by defining a custom NavigationBar which can inspect the current route. Would look something like this:

    class NavigationBar extends Navigator.NavigationBar {
      render() {
        var routes = this.props.navState.routeStack;
    
        if (routes.length) {
          var route = routes[routes.length - 1];
    
          if (route.display === false) {
            return null;
          }
        }
    
        return super.render();
      }
    }
    

    Using your example:

    render: function(){
      return (
        
          }
        />
      );
    }
    

提交回复
热议问题