我有一个应用程序,它有一个标题,中间带有徽标,左侧有一个开始按钮,右侧有一个打开抽屉的按钮。
我的问题是标题按钮。它们不起作用,我尝试了各种选择,但仍然不起作用。
这是我的代码,所以你可以看到它:
function GotoHome(navigation){
const scheme = useColorScheme();
return (
<TouchableOpacity style={{backgroundColor:'red'}} onPress={()=> { navigation.navigate('Inicio')}} >
<Icon
name ={"home"}
style={{paddingLeft:15}}
size={35}
color={scheme ==='dark' ? 'white' : '#36add9'}
/>
</TouchableOpacity>
)
}
function OpenDrawer(props){
const scheme = useColorScheme();
return(
<TouchableOpacity style={{backgroundColor:'red'}} onPress={() => props.navigation.dispatch(DrawerActions.toggleDrawer())}>
<Icon name={"menufold"} style = {{paddingRight:20, marginTop:2}} size={32} color={scheme ==='dark' ? 'white' : '#36add9'} />
</TouchableOpacity>
)
}
这里我传递了两个函数:
<Drawer.Navigator
drawerContent={(props)=> <Menu {...props}/> }
initialRouteName='Inicio'
drawerPosition='right'
screenOptions={{
headerRight:(props)=>(
<OpenDrawer/>
),
headerLeft:()=>(
<GotoHome/>
),
headerShown: true,
headerTitle: (props) => (
<Image
resizeMode='center'
style={{width: 210, height: 80, marginLeft:20 , resizeMode: 'contain'}}
source={logoimagen}
/>
我希望你能帮助我并提前致谢:)。