我正在尝试在我的反应原生应用程序的导航标题内添加一个自定义菜单图标按钮。我成功地做到了,但只要图标在标题中,新闻事件就不会触发。例如,如果我在这里有图标:
https://www.dropbox.com/s/xyah9ei43wgt1ut/menu_regular.png?dl=0
新闻发布会不起作用,但如果我在这里(将其移低):
https://www.dropbox.com/s/54utpr1efb3o0lm/menu_moved.png?dl=0
事件触发正常。
这是我当前的设置导航器:
const MainNavigator = createStackNavigator(
{
login: { screen: MainLoginScreen },
signup: { screen: SignupScreen },
profileScreen: { screen: ProfileScreen },
main: {
screen: createDrawerNavigator({
Home: createStackNavigator(
{
map: {
screen: MapScreen,
headerMode: 'screen',
navigationOptions: {
headerVisible: true,
headerTransparent: false,
headerLeft: (
<View style={{ position: 'absolute', left: 10, display: 'flex', zIndex: 11550 }}>
<Icon
raised
name='bars'
type='font-awesome'
color='rgba(255, 255, 255, 0)'
reverseColor='#444'
onPress={() => { console.log("press"); navigation.goBack() }}
reverse
/>
</View>
)
}
},
history: { screen: HistoryScreen },
foundItem: { screen: FoundItemScreen },
}
),
Settings: {
screen: SettingsScreen,
navigationOptions: ({ navigation }) => ({
title: 'Edit Profile',
})
}
}, {
contentComponent: customDrawerComponent,
drawerWidth: width * 0.8
}
)
}
}, {
headerMode: 'screen',
navigationOptions: {
headerTransparent: true,
headerLeftContainerStyle: { paddingLeft: 20 }
}
}
);
屏幕截图中的图标在里面headerLeft
。我也尝试了各种 zIndex 值,但没有运气。
提前致谢!
编辑:
抽屉在第一个项目上存在相同的问题,当它在标题上方时,按下事件不适用于抽屉项目的整个区域:
https://www.dropbox.com/s/krva5cgp7s59d13/drawer_opened.png?dl=0