我在领航员下有领航员IOS,想隐藏领航员的导航栏来使用领航员IOS的导航栏.有什么办法吗?
这是我见过的screenshot个.我需要领航员IOS的后端..
我想要构建的 struct 如下:
├── 领航员Route1
│ ├── 领航员IOSRoute1
│ ├── 领航员IOSRoute2
│ └── 领航员IOSRoute3
└── 领航员Route2
我的代码如下.(基本上是从例子中获得的.
领航员
render: function(){
return (
<领航员
initialRoute={ROUTE_STACK[this.getInitialRouteIndex()]}
initialRouteStack={ROUTE_STACK}
style={styles.container}
renderScene={this.renderScene}
navigationBar={
<领航员.NavigationBar
routeMapper={NavigationBarRouteMapper}
style={styles.navBar}
/>
}
/>
);
}
领航员IOS
render: function(){
var nav = this.props.navigator;
return (
<领航员IOS
style={styles.container}
ref="nav"
initialRoute={{
component: UserSetting,
rightButtonTitle: 'Done',
title: 'My View Title',
passProps: {nav: nav},
}}
tintColor="#FFFFFF"
barTintColor="#183E63"
titleTextColor="#FFFFFF"
/>
);
}
更新我的解决方案
我添加了一个用于更改状态的函数,该函数处理导航器的渲染,并将props 传递给组件以更改状态.
hideNavBar: function(){
this.setState({hideNavBar: true});
},
render: function(){
if ( this.state.hideNavBar === true ) {
return (
<领航员
initialRoute={ROUTE_STACK[0]}
initialRouteStack={ROUTE_STACK}
renderScene={this.renderScene}
/>
);
}else{
return (
<领航员
initialRoute={ROUTE_STACK[this.getInitialRouteIndex()]}
initialRouteStack={ROUTE_STACK}
style={styles.container}
renderScene={this.renderScene}
navigationBar={
<领航员.NavigationBar
routeMapper={NavigationBarRouteMapper}
style={styles.navBar}
/>
}
/>
);
}
}
和
render: function(){
var hideNavBar = this.props.hideNavBar;
return (
<领航员IOS
style={styles.container}
initialRoute={{
component: UserSetting,
rightButtonTitle: 'Done',
title: 'My View Title',
passProps: {hideNavBar: hideNavBar},
}}
tintColor="#FFFFFF"
barTintColor="#183E63"
titleTextColor="#FFFFFF"
/>
);
}