[英]react native : tab navigation style
Is there a way to change the style just of the ORANGE tab?有没有办法改变橙色标签的样式? Well I would be happy to know what is the way to handle such a situation.好吧,我很高兴知道处理这种情况的方法是什么。 I tried in several ways to change the style of the ORANGE.我尝试了几种方法来改变 ORANGE 的风格。 I use navigation 5 in my app.我在我的应用程序中使用导航 5。
<Tab.Navigator
tabBarOptions={{
activeTintColor: 'white',
inactiveTintColor: Colors.background_color,
indicatorStyle: {
backgroundColor: 'red',
height: 5,
},
style: {
elevation: 10,
backgroundColor: Colors.background_2,
},
labelStyle: {
fontSize: 18,
fontWeight: 'bold',
},
}}
backBehavior="none"
>
<Tab.Screen
name="APPLE"
listeners={({ route }) => ({
focus: () => {
setCurrentTabName(route.name);
},
})}
>
{() => <NetuneyDigum item={item} />}
</Tab.Screen>
<Tab.Screen
name="ORANGE"
component={BitzuaBdikotSadea}
listeners={({ route }) => ({
focus: () => {
setCurrentTabName(route.name);
},
})}
// initialParams={{ updateRecentFieldInput }} used for parameters not function
/>
<Tab.Screen
name="BANANA"
component={E_BitsuaDigdum}
listeners={({ route }) => ({
focus: () => {
setCurrentTabName(route.name);
},
})}
/>
</Tab.Navigator>
It depends exactly what you want to change but you can absolutely configure the icon and text per Screen in your Tab Bar Navigator using the options
parameter.这完全取决于您要更改的内容,但您可以使用options
参数在标签栏导航器中绝对配置每个屏幕的图标和文本。
<Tab.Screen
name="ORANGE"
component={BitzuaBdikotSadea}
listeners={({ route }) => ({
focus: () => {
setCurrentTabName(route.name);
},
})}
options={{
tabBarLabel: () => <Text>My Custom Label</Text>,
tabBarIcon: () => <MyCustomIcon />
}}
// initialParams={{ updateRecentFieldInput }} used for parameters not function
/>
You can pass more props such as "focused" to have more dynamic styling like changing colour when that tab is active.您可以传递更多道具,例如“focused”,以获得更多动态样式,例如在该选项卡处于活动状态时更改颜色。 Example: tabBarLabel: ({ focused }) => <MyCustomText focused={focused}>Custom Label</MyCustomText>
示例: tabBarLabel: ({ focused }) => <MyCustomText focused={focused}>Custom Label</MyCustomText>
Full list of options are documented here: https://reactnavigation.org/docs/5.x/material-bottom-tab-navigator/#options此处记录了完整的选项列表: https://reactnavigation.org/docs/5.x/material-bottom-tab-navigator/#options
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.