React Native:React导航抽屉项目上的自定义样式

问题描述 投票:0回答:1

我目前正在尝试使用React Navigation(https://reactnavigation.org/docs/drawer-navigator)创建一个CustomDrawerComponent,其中每个项目应具有不同的样式(背景颜色,文本颜色,高度)。我的问题是我找不到为每个屏幕设置自定义样式的方法。

实现这样的目标的最佳方法是什么,在drawerItemStyle上我可以为该特定项目设置属性:

export const PrimaryNavigator = createDrawerNavigator(
  {
    welcome: { screen: WelcomeScreen, drawerItemStyle: { backgroundColor: "#000" }  },
    demo: { screen: DemoScreen, drawerItemStyle: { backgroundColor: "#333" } },
  },
  {
    hideStatusBar: true,
  },
) 
react-native react-navigation react-native-navigation react-navigation-drawer
1个回答
0
投票

您可以参考以下视频以轻松自定义抽屉项目,Customize drawer navigation items

© www.soinside.com 2019 - 2024. All rights reserved.