【发布时间】:2021-09-08 11:48:16
【问题描述】:
我想在我的 TabBar 上放置一个细渐变边框。我尝试使用 BorderTopColor 样式简单地实现它,但 React Native 默认不支持渐变。所以我安装了www.npmjs.com/package/react-native-linear-gradient。但是,我不知道将渐变容器放置在我的 TabBar 和 Screens 之间。
这是我目前所拥有的:
const Tab = createBottomTabNavigator();
const App: () => Node = () => {
const customTabBarStyle = {
activeTintColor: '#ffffff',
inactiveTintColor: '#b9b9b9',
showLabel: false,
style: {
backgroundColor: '#1e1e1e',
height: 200
}
};
return (
<NavigationContainer>
<LinearGradient start={{x: 0, y: 0}} end={{x: 1, y: 0}} colors={['red', 'yellow']} style={{height: 2}} />
<Tab.Navigator
tabBarOptions = {customTabBarStyle}
screenOptions={{ tabBarStyle: { backgroundColor: '#1e1e1e', borderTopWidth: 0, elevation: 0}, headerStyle: { backgroundColor: '#1e1e1e'}, headerTitleStyle: {color: 'white'}}}>
<Tab.Screen
name="PrimaryMarket"
component={PrimaryMarketScreen}
options={{
tabBarIcon: ({color}) => (
<Icon name="shopping-cart" size={40} color={color} />
),
}}
/>
</Tab.Navigator>
</NavigationContainer>
);
};
这就是我想要的:
【问题讨论】:
标签: react-native react-navigation gradient