我正在使用 React Navigation 5 和@react-navigation/bottom-tabs 的createBottomTabNavigator 创建一个自定义标签栏,
问题:红色图标只能在标签栏范围内点击,一旦我越过了标签栏的灰线,我就无法点击该图标。
我已经使用以下代码为标签屏幕创建了它
<Tab.Screen
name="Scan"
component={Scan}
options={({ navigation }) => {
return {
tabBarIcon: () => <MiddleIcon navigation={navigation} />,
};
}}
/>
我已经尝试将整个视图包裹在可触摸的不透明度中,但它仍然只能在标签栏的范围内触摸
中间图标组件:
const MiddleIcon = ({ navigation }) => {
return (
<TouchableOpacity
onPress={() => navigation.navigate('Scan')}
style={styles.container}>
<View style={styles.imageContainer}>
<Image
source={require('../../../assets/images/shared/scan_icon.png')}
/>
</View>
</TouchableOpacity>
);
};
export default MiddleIcon;
const styles = StyleSheet.create({
container: {
position: 'absolute',
bottom: 20,
height: 58,
width: 58,
borderRadius: 58,
backgroundColor: colors.primaryColor,
justifyContent: 'center',
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 3,
},
shadowOpacity: 0.29,
shadowRadius: 4.65,
elevation: 7,
flex: 1,
},
icon: {
width: 40,
height: 40,
tintColor: '#fff',
alignContent: 'center',
},
imageContainer: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
width: 30,
height: 30,
},
});
问题:如何使它在底部标签栏的边界之外可点击?
