Reputation: 4101
Similar to this question, but I want to change the color of the icon as well - not just the text.
Here is the code in question:
HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarOptions: {
activeTintColor: '#6CC7BD',
inactiveTintColor: '#CCCCCC',
},
tabBarIcon: ({focused}) => (
<TabBarIcon
focused={focused}
name={
Platform.OS === 'ios'
? `ios-information-circle${focused ? '' : '-outline'}`
: 'md-information-circle'
}
/>
)
}
According to this thread on Github, I should try this:
HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarOptions: {
activeTintColor: '#6CC7BD',
inactiveTintColor: '#CCCCCC',
},
tabBarIcon: ({focused}) => <TabBarIcon name={
Platform.OS === 'ios'
? `ios-information-circle${focused ? '' : '-outline'}`
: 'md-information-circle'
} color={this.activeTintColor}/>
}
But the information circle is still grey:
Also tried color={this.tabBarOptions.activeTintColor}
, which caused an error:
Any other suggestions?
Edit - Also tried:
HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarOptions: {
activeTintColor: '#6CC7BD',
inactiveTintColor: '#CCCCCC',
},
tabBarIcon: ({activeTintColor}) => (
<TabBarIcon
activeTintColor={activeTintColor}
name={
Platform.OS === 'ios'
? `ios-information-circle${activeTintColor ? '' : '-outline'}`
: 'md-information-circle'
}
color={this.activeTintColor}
/>
)
}
Upvotes: 0
Views: 2580
Reputation: 506
did you try to add all the props:
tabBarIcon: ({focused, ...restProps}) => (
<TabBarIcon
name={
Platform.OS === 'ios'
? `ios-information-circle${activeTintColor ? '' : '-outline'}`
: 'md-information-circle'
}
focused={focused}
{...restProps}
/>
)
Upvotes: 2