React native 如何在选项卡栏(反应导航)中动态更改activeTintColor?

React native 如何在选项卡栏(反应导航)中动态更改activeTintColor?,react-native,react-navigation,React Native,React Navigation,我正在我的应用程序中使用react导航,我想知道如何动态更改选项卡栏中的activeTintColor 我有这样的代码,但它不会改变activeTintColor: static navigationOptions = ({ navigation, screenProps }) => ({ actionButton: { title: _('create'), icon: 'plus', onPress: () => navigatio

我正在我的应用程序中使用
react导航
,我想知道如何动态更改选项卡栏中的
activeTintColor

我有这样的代码,但它不会改变activeTintColor:

  static navigationOptions = ({ navigation, screenProps }) => ({
    actionButton: {
      title: _('create'),
      icon: 'plus',
      onPress: () => navigation.navigate('EventCreate')
    },
    tabBarLabel: _('calendar'),
    tabBarIcon: ({focused}) => <Icon featherName="calendar" active={focused}/>,
    tabBarOptions: { activeTintColor:'red'}
  }) 
静态导航选项=({navigation,screenProps})=>({
操作按钮:{
标题:((“创建”),
图标:“加号”,
onPress:()=>navigation.navigate('EventCreate')
},
tabBarLabel:((“日历”),
tabBarIcon:({focused})=>,
选项卡选项:{activeTintColor:'red'}
}) 

您可以通过标记自定义选项卡栏组件来完成此操作

自定义选项卡栏组件可以访问这些

导航状态对象的定义如中所示

import { TabNavigator } from 'react-navigation';

const TabBar = TabNavigator.Presets.Default.tabBarComponent

const CustomTabBar = ({...props}) => {
    props.activeTintColor = //... change the color based on screen navigation state 
    return <TabBar {...props} />
}
const CustomTabs = TabNavigator(
    {
        // ...Screens
    },
    {
        tabBarComponent: CustomTabBar,
    },
);