我想在汉堡包菜单上点击抽屉组件,而不是从左向右拖动,反之亦然。这就是代码
主屏幕 ...
<CustomHeader title="Home" drawerOpen={() => this.props.navigation.navigate('DrawerOpen')} />
... 自定义标题
<Header style={styles.themeBGColor}>
<Left><Icon name="ios-menu" onPress={() => this.props.drawerOpen()} /></Left>
<Body>
<Title>{this.props.title}</Title>
</Body>
<Right />
</Header>
App.js
const MyApp = DrawerNavigator({
// For each screen that you can navigate to, create a new entry like this:
Home: {
screen: HomeScreen,
},
Categories: {
screen: CategoryScreen,
},
},
{
initialRouteName: 'Home',
drawerPosition: 'left',
contentComponent: CustomDrawerContentComponent,
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
});
答案 0 :(得分:0)
添加此行
<Icon name="ios-menu" onPress={() => this.props.navigation.navigate('DrawerToggle');}>
和
const MyApp = DrawerNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions: ({navigation}) => ({
drawerLockMode: 'locked-closed',
drawerPosition: 'right',
})
},
Categories: {
screen: CategoryScreen,
},
},
{
initialRouteName: 'Home',
contentComponent: CustomDrawerContentComponent,
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle',
});
答案 1 :(得分:0)
如果您正在使用2018-05-09 13:27:31.319283
中的抽屉导航器,请使用react-navigation
功能打开导航抽屉。
openDrawer
关闭导航抽屉使用
onPress={() => this.props.navigation.openDrawer()}