1. 目前使用的NavigatorIOS組件,在做登錄模塊實現隱藏導航欄,第二頁再顯示導航欄,通過state來控制,嘗試了多次,在第二頁返回首頁時,導航欄不能再次隱藏。確認state值已經改變了。
<NavigatorIOS initialRoute={{ component: Login, title:'', passProps:{ setBarHidden: this.setBarHidden.bind(this), }, }} navigationBarHidden={this.setBarHidden} barTintColor='#fff' translucent={true} />
2. 思來想去,只能讓導航欄一直隱藏,自己寫一個導航欄。
<TouchableHighlight underlayColor="#fff" onPress={this._back.bind(this)}> <View style={{flexDirection:'row',justifyContent:'flex-start'}}> <View style={styles.go}></View> <Text style={styles.back}>返回</Text> </View> </TouchableHighlight>
_back(){ this.props.navigator.pop(); }
go:{ borderLeftWidth: 4 * Util.pixel, borderBottomWidth: 4 * Util.pixel, width:10, height:10, transform:[{rotate: '45deg'}], borderColor: '#3BC1FF', marginRight:2, marginLeft:10, marginTop:3, }