【问题标题】:Custom View as background for StackNavigator自定义视图作为 StackNavigator 的背景
【发布时间】:2018-06-07 20:05:28
【问题描述】:

我需要在堆栈导航器下方使用一张图片或类似的东西。 在 StackNavigator 中,我可以设置背景颜色、不透明度(视图样式)等。但无法设置一个背景图像或自定义视图组件。此外,如果设置为每个屏幕,则不利于屏幕翻译。

我试图这样包装:

 <ImageBackground>
    <MyStackNavigator/>
 </ImageBackground/>

没有结果。 你能帮助我吗? +1 任何尝试

【问题讨论】:

  • 在哪里可以找到解决方案?

标签: react-native stack-navigator


【解决方案1】:

我找到了解决办法

导航器:

const AuthStackNavigator = StackNavigator({
   LANDING: {
       screen: LandingScreen
   },
   SIGN_IN: {
       screen: SignInScreen
   },
   {
       mode: 'card',
       cardStyle: { backgroundColor: 'transparent' },
       transitionConfig: () => ({
           containerStyle: {
               backgroundColor: 'transparent',
           }
       }),
       initialRouteName: 'LANDING',
   }
);

渲染:

render() {
    return <ImageBackground
        style={{
            width: null,
            height: null,
            backgroundColor: 'transparent',
            flex: 1,
        }}
        source={landing_background}
    >
        <AuthStackNavigator
            ref='navigator'
        />
    </ImageBackground>
}

【讨论】:

  • 我收到错误 Invariant Violation:此导航器缺少导航道具,请添加导航道具和静态路由器
  • 我的也可以工作,但前一个屏幕的 50% 在当前屏幕下方仍然可见。如何解决这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-23
  • 2023-03-23
相关资源
最近更新 更多