[英]React Navigation how to hide tabbar top-border on a individual screen
It is easy to hide the border on every Screen by doing the following code on Navigator level通过在导航器级别执行以下代码很容易隐藏每个屏幕上的边框
<Tab.Navigator
tabBarOptions={{
style: {
borderTopWidth: 0,
},
}}
>
But how to hide the border on a single Screen?但是如何在单个屏幕上隐藏边框? I've already tried the following but it has no effect
我已经尝试了以下但没有效果
React.useLayoutEffect(() => {
navigation.setOptions({
tabBarOptions: {
style: {
borderTopWidth: 0,
},
},
});
}, [navigation]);
If we would like to make changes from the child component then we have to access the parent component navigation props.如果我们想从子组件进行更改,那么我们必须访问父组件的导航道具。
Have a try with the below code which might help you:试试下面的代码,它可能对你有帮助:
React.useLayoutEffect(() => {
navigation.dangerouslyGetParent().setOptions({
tabBarOptions: {
style: {
borderTopWidth: 0,
},
},
});
}, [navigation]);
@react-navigation^v6.x
you need to add tabBarStyle: { borderTopWidth: 0, elevation: 0} in the screenOptions prop to hide top border in bottom tab bar for both ios and android. @react-navigation^v6.x
您需要在 screenOptions 道具中添加 tabBarStyle: { borderTopWidth: 0, elevation: 0} 以隐藏 ios 和 android 的底部标签栏中的顶部边框。
For example:例如:
<Tab.Navigator screenOptions={{ tabBarStyle: { borderTopWidth: 0, elevation: 0, }, }}> </Tab.Navigator>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.