reactjs - 反应导航覆盖抽屉安全区域视图
问题描述
我如何覆盖/自定义随/SafeAreaView
提供的默认值。react-navigation
react-navigation-drawer
来源:https ://reactnavigation.org/docs/en/handling-iphonex.html
我尝试通过在组件/视图中包含以下内容来覆盖,<SafeAreaView></SafeAreaView>
但它最终具有重复的SafeAreaView
UI。这意味着它附加另一个SafeAreaView
而不是覆盖默认内置SafeAreaView
的react-navigation
.
<SafeAreaView
style={{flex: 1}}
forceInset={{ bottom: 'never' }}>
...
</SafeAreaView>
解决方案
您需要contentComponent
为您的抽屉创建一个自定义:
const DrawerNavigatorConfig = {
contentComponent: props => <Menu {...props} />
};
createDrawerNavigator(RouteConfigs, DrawerNavigatorConfig);
您将需要实现该Menu
组件......这可能是:
const Menu = () => {
return (
<SafeAreaView
forceInset={{ top: 'always', bottom: 'never' }}
style={{flex: 1}}
>
...
</SafeAreaView>
);
};
推荐阅读
- java - logback 以编程方式重写 xml 配置
- kubernetes - 如何在 Kubernetes 的所有区域之间均匀分布 Pod?
- google-chrome - Gmail 插件 - 无法打开外部链接,即使它们已在允许列表中定义
- python - 如何使金额增加一定数量
- apollo - 如何解决此 Apollo Control Cache 错误?
- javascript - 为每一行设置边框,非常非常慢
- javascript - 如何加快样式页面
- css - 更改图像的不透明度颜色
- powershell - 在两列Powershell中显示输出
- folium - TimeSliderChoropleth 自动播放