Som*_*ame 2 tabnavigator reactjs react-native react-navigation
如何隐藏标签TabNavigator并仅显示icons?如果我执行以下操作:
const Tabs = TabNavigator({
Home: {
screen:MainHome,
navigationOptions: ({ navigation }) => ({
title: "Home", //Tried to hide this for next tab Search.
tabBarIcon: ({ tintColor, focused }) => <View><MaterialIcons name="home"/></View>
})
},
Search: {
screen:TestComp1,
navigationOptions: ({ navigation }) => ({
//If no title it shows the name as Search.
tabBarIcon: ({ tintColor, focused }) => <View><MaterialIcons name="accessibility"/></View>
})
}
}, {
tabBarPosition: 'bottom',
tabBarOptions: {
showIcon: true,
activeTintColor: '#e91e63', //Not working for icons.
inactiveBackgroundColor: 'green', // Not working at all.
style: {backgroundColor: '#3498DB', height: 60, padding:0, margin:0}
}
});
Run Code Online (Sandbox Code Playgroud)
如果我title从navigationOptions它中删除它显示Tab(Home或Search)的名称.我想只显示图标并更改活动的颜色icon.activeTintColor不适用于图标.
以下是显示没有标签的图标的示例.
tabBarOptions: {
showLabel: false,
showIcon: true,
tintColor: '#333',
activeTintColor: '#aaa',
}
Run Code Online (Sandbox Code Playgroud)
我定义了tintColor和activeTintColor来更改活动选项卡的标签颜色.要更改活动选项卡的图标颜色,您需要为每个选项卡定义tabBarIcon并将tintColor传递给它.例如,如果您有一个搜索选项卡,您可以这样做:
Search: {
screen: SearchScreen,
navigationOptions:{
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-search" style={{color:tintColor}} />
)
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5732 次 |
| 最近记录: |