2017-04-24 66 views
0

我想知道如何隱藏這是由默認實現react-navigationhttps://reactnavigation.org/如何隱藏工具欄上的反應導航

後添加工具欄我有兩個屏幕 - 啓動屏幕,在這裏我不想一個工具欄和第二屏可以有工具欄的地方。

index.android.js

/** 
* https://github.com/facebook/react-native 
* @flow 
*/ 

import React, { Component } from "react"; 
import { 
    AppRegistry, 
    Image, 
    View, 
    Text, 
    Button, 
    StyleSheet 
} from "react-native"; 
import { StackNavigator } from "react-navigation"; 
import EnableNotificationScreen from "./EnableNotification"; 

class SplashScreen extends Component { 
    render() { 
    console.disableYellowBox = true; 
    const { navigate } = this.props.navigation; 
    return (
     <View style={styles.container}> 
     <Image source={require("./img/talk_people.png")} /> 
     <Text style={{ fontSize: 22, textAlign: "center" }}> 
      Never forget to stay in touch with the people that matter to you. 
     </Text> 
     <View style={{ width: 240, marginTop: 30 }}> 
      <Button 
      title="CONTINUE" 
      color="#FE434C" 
      onPress={() => navigate("EnableNotification")} 
      /> 
     </View> 
     </View> 
    ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
    backgroundColor: "#FFFFFF", 
    alignItems: "center", 
    justifyContent: "center", 
    padding: 16, 
    flex: 1, 
    flexDirection: "column" 
    } 
}); 

const ScheduledApp = StackNavigator(
    { 
    Splash: { screen: SplashScreen }, 
    EnableNotification: { screen: EnableNotificationScreen } 
    }, 
    { 
    initialRouteName: "Splash" 
    } 
); 

AppRegistry.registerComponent("Scheduled",() => ScheduledApp); 

EnableNotification.js

/** 
* https://github.com/facebook/react-native 
* @flow 
*/ 

import React, { Component } from "react"; 
import { View, Text } from "react-native"; 

export default class EnableNotificationScreen extends Component { 
    render() { 
    return <View><Text>Enable Notification</Text></View>; 
    } 
} 

回答

1

爲了隱藏工具欄,你可以試試下面的代碼:

const ScheduledApp = StackNavigator(
    { 
    Splash: { screen: SplashScreen, 
     navigationOptions: { 
     header: { 
     visible: false 
     } 
    } 
}, 
    EnableNotification: { screen: EnableNotificationScreen, 
    navigationOptions: { 
     header: { 
     visible: true 
     } 
    } 
} 
    }, 
    { 
    initialRouteName: "Splash" 
    } 
); 

乾杯: )

+0

'飛濺:{屏幕:閃屏, navigationOptions:{ 頭:{ 可見:假 } }'什麼語法是這個ES6的? –

+0

這只是一個正常的鍵值對沒有別的... – Codesingh

4
static navigationOptions = { 
    header: null , 
    }; 

這對我的作品

class SplashScreen extends Component { 

    static navigationOptions = { 
    header: null , 
    }; 

    render() { 
    console.disableYellowBox = true; 
    const { navigate } = this.props.navigation; 
    return (
     ... 
    ); 
    } 
} 
+0

爲我工作。謝謝!! –