react-native - 在React导航v5中突出显示当前事件抽屉菜单

标签 react-native react-navigation react-native-navigation react-navigation-drawer react-navigation-v5

我已经使用React导航版本:5.X创建了一个自定义的抽屉导航器,
但是当前的事件选项卡未在自定义抽屉菜单中突出显示。

  • 我在DrawerItem元素中添加了“activeTintColor”,但未将其应用于事件项目。
  • 我还在抽屉ContentOptions中添加了activeTintColor。但也没有得到应用。他们有什么办法在自定义抽屉组件中使用此通用选项吗?
  • 我在DrawerItem元素中使用了“icon”,在其中我根据react导航文档添加了默认的props(颜色,焦点,大小)。因此,图标的颜色为“灰色”(可能是默认行为)。如何更改此默认props值?
  • 在“icon”中的默认 Prop “focused”也不起作用。所选标签的图标不会更改。

  • 请找到以下代码图像。如果我有任何错误,请通知我。

    导航器代码:

    enter image description here

    自定义抽屉组件:

    enter image description here

    当前事件选项卡:主页

    enter image description here

    最佳答案

    您可以使用 DrawerItemList 来显示 Drawer。在 Drawer.Navigator 中定义的屏幕,如下所示:-

    1)定义抽屉导航器:-

    <Drawer.Navigator drawerContentOptions={{ activeBackgroundColor: '#5cbbff', activeTintColor: '#ffffff' }} drawerContent={props => <CustomDrawerContent {...props} />}>
    <Drawer.Screen name="Home" component={HomeScreen} options={{
            drawerIcon: config => <Icon
                size={23}
                name={Platform.OS === 'android' ? 'md-list' : 'ios-list'}></Icon>
        }} />
    

    />

    2)在CustomDrawerContent函数中:-
    <DrawerContentScrollView {...props} >
    ----- your custom header ----
    <DrawerItemList {...props} />
    ----- add other custom components, if any ----
    </DrawerContentScrollView>
    

    那为我解决了这个问题。

    关于react-native - 在React导航v5中突出显示当前事件抽屉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60622829/

    相关文章:

    react-native - 我尝试了 React Native Tab View。路由导航在 renderScene 组件中不起作用

    android - React Native PanResponder 限制X位置

    reactjs - React Navigation v3 与 React Native Navigation v2

    javascript - 如何使用 React Navigation 在 React Native 中以编程方式在 Android 上隐藏标签栏?

    ios - 如何在 ios 上的 React-native-navigation(V1) 中添加后退按钮以关闭模式屏幕

    react-native - 使用 React Native Navigation V2 时关闭推送动画

    ios - react native : images with space in name won't load in IOS (device, 不是 https 问题)

    react-native - Metro Bundler 准备就绪。错误 ENOSPC : System limit for number of file watchers reached, watch

    android - React Native StackNavigator 在重新进入时消失

    reactjs - 如何在 react 导航组件之间保持共同状态?