我目前正在尝试使用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,
},
)
您可以参考以下视频以轻松自定义抽屉项目,Customize drawer navigation items