Gio*_*ili 5 navigation-drawer react-native react-native-navigation react-navigation-drawer
我将抽屉设置在右侧,但屏幕标题中的汉堡包图标保持默认左侧,是否有任何属性可以通过将位置更改为右侧?我知道应该通过配置自定义标头来完成,但我不想过度设计我的小项目。
小智 10
使用react-navigation v6,添加DrawerToggleButton,如下所示:
import { createDrawerNavigator, DrawerToggleButton } from '@react-navigation/drawer';
...
<Drawer.Navigator
screenOptions={{
drawerPosition: 'right',
headerLeft: false,
headerRight: () => <DrawerToggleButton />,
}}>
//or in the options Drawer.Screen for just one screen
<Drawer.Screen name="Home" component={Home}/>
...
</Drawer.Navigator>Run Code Online (Sandbox Code Playgroud)
小智 4
import {DrawerActions} from '@react-navigation/native';
<Drawer.Navigator
screenOptions={{
drawerPosition: 'right',
}}>
<Drawer.Screen
name="Home"
component={Home}
options={{
headerStyle: {
backgroundColor: 'orange',
},
headerTintColor: 'black',
headerLeft:false,
headerRight: () => (
<TouchableOpacity onPress={() => navigation.dispatch(DrawerActions.openDrawer())}>
<Icon name="menu" size={30} color="black" />
</TouchableOpacity>
),
}}
/>
<Drawer.Screen name="Standings" component={Standings} />
</Drawer.Navigator>
Run Code Online (Sandbox Code Playgroud)
这对我有用。
| 归档时间: |
|
| 查看次数: |
10411 次 |
| 最近记录: |