隐藏抽屉导航标题

时间:2018-05-28 04:52:49

标签: react-native react-navigation

我正在尝试隐藏Drawer Header以响应本机应用程序。目前,使用react-navigation ^1.5.12。 *我想删除灰色标题

enter image description here

我的代码看起来像这样。 Router.js

const HomeStack = DrawerNavigator({
  Home: { screen: Home },
  Message: { screen: Message },
  History: { screen: History },
  Settings: { screen: Settings },
}, {
  contentComponent: DrawerMenu,
  drawerWidth: 240,
  // Explicitly set the default screen to use
  initialRouteName: 'Home',
});

export default const MainStack = StackNavigator({
  LoggedInHome: { screen: HomeStack },
  Notification: { screen: Notification },
}, {
  // Explicitly set the default screen to use
  initialRouteName: 'Home',
});

我也在每个屏幕上添加了header: null

DrawerMenu.js

export default class DrawerMenu extends React.Component {
  static navigationOptions = {
    header: null
  }

  navigateToScreen = (route) => () => {
    const navigateAction = NavigationActions.navigate({
      routeName: route
    });
    this.props.navigation.dispatch(navigateAction);
  }

  render() {
    return (
      <View>
        <TouchableOpacity
          onPress={this.navigateToScreen('Home', { isStatusBarHidden: false })}
        >
          <Text>Home</Text>
        </TouchableOpacity>
...

2 个答案:

答案 0 :(得分:0)

你应该这样试试:

function OperationHours($open, $close){
    $status = 'closed';
    $current_time = date('h:iA');
    $nowTime = DateTime::createFromFormat('h:iA', $current_time);
    $openTime = DateTime::createFromFormat('h:iA', $open);
    $closeTime = DateTime::createFromFormat('h:iA', $close);
        if ($nowTime > $openTime && $nowTime < $closeTime){
            $status = 'open';
        }
    return $status;
}

/*function OperationHours($open, $close){
    $status = 'closed';
    $timestamp = time();
    $currentTime = (new DateTime())->setTimestamp($timestamp);
    $openTime = DateTime::createFromFormat('h:iA', $open);
    $closeTime = DateTime::createFromFormat('h:iA', $close);
        if(($openTime < $currentTime) && ($currentTime < $closeTime)) {
            $status = 'open';
        }
    return $status;
}*/

echo OperationHours('09:00AM', '03:30AM');

答案 1 :(得分:0)

您应该在抽屉的实例化中设置导航选项:

const HomeStack = DrawerNavigator({
  Home: {
    screen: Home,
    navigationOptions: { header: null }
  },
  ...