我正在开发一个应用程序,它的底部选项卡导航器中有三个屏幕。当我从一个屏幕转到另一个屏幕时,我已经能够更改标签颜色,但是,我也无法更改图标的颜色。这是到目前为止的样子的一个例子。
这是我控制此代码的App.js代码。我真的很感谢任何帮助或指导。在此先感谢您的帮助!
App.js:
function MainTabNavigator() {
return (
<Tab.Navigator
tabBarOptions={{
activeTintColor: '#e64951',
}}
>
<Tab.Screen options={{
headerShown: false, tabBarIcon: ({ tintColor }) => (
<Entypo name="home" size={30} color={tintColor} />
)
}} name="home" component={Home} />
<Tab.Screen options={{
headerShown: false, tabBarIcon: () => (
<FontAwesome5 name="plus" size={30} color="black" />
)
}} name="Add Friends" component={AddFriends} />
<Tab.Screen options={{
headerShown: false, tabBarIcon: ({ tintColor }) => (
<FontAwesome name="user" size={30} color={tintColor} />
)
}} name="Profile" component={Profile} />
</Tab.Navigator>
)
}
您将错误的论据传递给tabBarIcon
prop。您应该通过color
而不是tintColor
。
tabBarIcon: ({ color }) => (
<Entypo name="home" size={30} color={color} />
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句