React native 当当前选项卡在react navigation 5中处于活动状态时,如何在底部选项卡顶部添加一行
我想在底部选项卡的顶部添加行,如何添加? 像这个问题 反应导航版本:React native 当当前选项卡在react navigation 5中处于活动状态时,如何在底部选项卡顶部添加一行,react-native,react-navigation-v5,react-navigation-bottom-tab,React Native,React Navigation V5,React Navigation Bottom Tab,我想在底部选项卡的顶部添加行,如何添加? 像这个问题 反应导航版本: "@react-navigation/bottom-tabs": "^5.9.2", "@react-navigation/native": "^5.7.6", "@react-navigation/stack": "^5.9.3", "react": "16.13.1"
"@react-navigation/bottom-tabs": "^5.9.2",
"@react-navigation/native": "^5.7.6",
"@react-navigation/stack": "^5.9.3",
"react": "16.13.1",
"react-native": "0.63.3",
您可以使用如下自定义按钮
const CustomTabButton = (props) => (
<TouchableOpacity
{...props}
style={
props.accessibilityState.selected
? [props.style, { borderTopColor: 'red', borderTopWidth: 2 }]
: props.style
}
/>
);
const CustomTabButton=(道具)=>(
);
并在初始化导航时将其作为选项卡按钮提供
<Tab.Navigator>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarButton: CustomTabButton,
}}
/>
<Tab.Screen
name="Settings"
component={SettingsScreen}
options={{
tabBarButton: CustomTabButton,
}}
/>
</Tab.Navigator>
你可以试试下面的小吃
您可以使用如下自定义按钮
const CustomTabButton = (props) => (
<TouchableOpacity
{...props}
style={
props.accessibilityState.selected
? [props.style, { borderTopColor: 'red', borderTopWidth: 2 }]
: props.style
}
/>
);
const CustomTabButton=(道具)=>(
);
并在初始化导航时将其作为选项卡按钮提供
<Tab.Navigator>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarButton: CustomTabButton,
}}
/>
<Tab.Screen
name="Settings"
component={SettingsScreen}
options={{
tabBarButton: CustomTabButton,
}}
/>
</Tab.Navigator>
你可以试试下面的小吃
如何将自定义参数传递给CustomTabButton?@Hugo你是说自定义道具吗?tabBarButton具有一个函数,您可以传递道具并返回组件Show您可以将自定义参数传递给CustomTabbuton吗?@Hugo您是说自定义道具吗?tabBarButton具有传递道具和返回组件的功能