HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
name={Platform.OS === 'ios' ? 'ios-home' : 'md-home'}
/>
),
tabBarOptions: {
activeTintColor: '#cd077d',
},
};
我正在尝试更改我的TabBarIcon的颜色我尝试过ActiveTintColor但这似乎只是改变了文本颜色而不是图标颜色,它当前是活动时的默认蓝色。
试试这个
HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarIcon: ({focused, tintColor }) => (
<TabBarIcon
focused={focused}
name={Platform.OS === 'ios' ? 'ios-home' : 'md-home'}
tintColor={{ tintColor }}
/>
),
tabBarOptions: {
activeTintColor: '#cd077d',
},
};
你能不能设置返回的TabBarIcon组件的颜色?在官方文档中查看tintColor:https://reactnavigation.org/docs/en/tab-based-navigation.html
export default createBottomTabNavigator(
{
Home: HomeScreen,
Settings: SettingsScreen,
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, horizontal, tintColor }) => {
return <IconComponent name={iconName} size={25} color={tintColor} />;
},
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
},
}
);