gpt4 book ai didi

css - react native 底部标签栏样式添加凹凸

转载 作者:行者123 更新时间:2023-12-05 06:22:00 24 4
gpt4 key购买 nike

有人知道如何设计底部标签栏的样式,以便拥有这样的东西吗?

Bottom Tab Bar

我能够设计每个元素并设计整个底部栏以在左右两侧添加半径,但困难的部分是相机图标上方的小凸起,我不知道该怎么做

我的导航文件如下所示:

const TabNavigator = createMaterialBottomTabNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<Image source={home_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
:
<Image source={home_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
),
}
},
Cart2: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<Image source={ranking_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
:
<Image source={ranking_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
),
}
},
Cart3: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<Image source={photo_icon} resizeMode="contain"
style={{
width: 25,
height: 25,
position: 'absolute',
top: -10,
tintColor: tintColor,
marginBottom: 20
}}/>
:
<Image source={photo_icon} resizeMode="contain"
style={{width: 25, height: 25, tintColor: tintColor}}/>
),
}
},
Cart4: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<Image source={gallery_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
:
<Image source={gallery_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
),
}
},
Cart5: {
screen: HomeScreen,
navigationOptions: {
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<Image source={mission_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
:
<Image source={mission_icon} resizeMode="contain"
style={{width: 20, height: 20, tintColor: tintColor}}/>
),
}
},
},
{
initialRouteName: "Home",
activeColor: Color.primary,
barStyle: {
backgroundColor: Color.white,
borderTopLeftRadius: 30,
borderTopRightRadius: 30,
borderBottomStartRadius: 30,
borderBottomEndRadius: 30,
overflow: 'hidden'
},
},
);
export default createAppContainer(TabNavigator)

我正在使用这个库 material-bottom-tabs与世博会

最佳答案

感谢同事解决问题您需要使用“createBottomTabNavigator”而不是“createMaterialBottomTabNavigator”,因为 Material Bottom Tab 不支持溢出,因此您不能将圆圈添加为越界的 Item。

我的元素现在看起来像这样:

Photo: {
screen: HomeScreen,
navigationOptions: {
tabBarLabel: ' ',
tabBarIcon: ({tintColor}) => (tintColor === Color.primary ?
<TouchableOpacity
activeOpacity={1}
style={{
borderRadius: Math.round((150 * 0.5) + (150 * 0.5)) / 2,
width: 150 * 0.5,
height: 150 * 0.5,
backgroundColor: '#fff',

justifyContent: 'center',
alignItems: 'center'
}}
underlayColor='#ccc'
>

<Image source={photo_icon} resizeMode="contain"
style={{
width: 30,
height: 30,
tintColor: tintColor,
}}/>
</TouchableOpacity>
:
<TouchableOpacity
activeOpacity={1}
style={{
borderRadius: Math.round((150 * 0.5) + (150 * 0.5)) / 2,
width: 150 * 0.5,
height: 150 * 0.5,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center',
}}
underlayColor='#ccc'
>

<Image source={photo_icon} resizeMode="contain"
style={{
width: 30,
height: 30,
tintColor: tintColor,
}}/>
</TouchableOpacity>
),
}
},

现在删除“barStyle”以像这样使用“tabBarOptions”:

tabBarOptions: {
activeTintColor: Color.primary,
style: {
borderTopWidth: 0,
width: '100%',
borderRadius: 30,
backgroundColor: '#fff',
},
}

然后您将获得我在上一个屏幕中想要的精确渲染,谢谢

关于css - react native 底部标签栏样式添加凹凸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59481314/

24 4 0