【发布时间】:2023-04-01 01:13:01
【问题描述】:
有什么方法可以实现吗? 我正在使用 react-navigation 5,并根据 Bottom-tab-navigator
我用于底栏的代码如下
import React from 'react';
import { View, StyleSheet } from 'react-native';
import colors from 'styles/colors';
import TabBarItem from './TabBarItem/TabBarItem';
const homeIcon = require('assets/maps.png');
export enum Item {
Home,
ProfileView,
}
const DashboardTabBar: React.FC<{}> = ({ state, descriptors, navigation }) => {
return (
<View style={styles.container}>
<View style={styles.innerContainer}>
{state.routes.map((route, index) => {
const { options } = descriptors[route.key];
const isFocused = state.index === index;
const onPress = () => {
const event = navigation.emit({
type: 'tabPress',
target: route.key,
});
if (!isFocused && !event.defaultPrevented) {
navigation.navigate(route.name);
}
};
const onLongPress = () => {
navigation.emit({
type: 'tabLongPress',
target: route.key,
});
};
return (
<TabBarItem
icon={homeIcon}
isFocused={isFocused}
onPress={onPress}
onLongPress={onLongPress}
options={options}
key={route.key}
/>
);
})}
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
padding: 10,
paddingBottom: 18,
backgroundColor: 'red', // I tried with 'transparent' here, but i see a white background instead of transparent
},
innerContainer: {
height: 60,
backgroundColor: colors.GREY_L_10,
flexDirection: 'row',
justifyContent: 'space-evenly',
alignItems: 'center',
borderRadius: 50,
borderWidth: 1,
borderColor: colors.GREY,
},
});
export default DashboardTabBar;
就我查看代码而言,我找不到任何使其透明的方法。
【问题讨论】:
-
你能分享生成底部标签的代码吗?你在哪里设置红色?
-
@user3009752 您希望在后台看到什么?图像、某种颜色或者根视图背景闪屏?
-
在后台我有一个垂直滚动视图,这是一个很长的列表。如果我在 react native 底部导航器后面有一个项目,我希望在它后面可见
标签: react-native react-navigation react-navigation-v5 react-navigation-bottom-tab