2016-11-04 45 views
1

因为当我这样做时,什么都不呈现。 最后的想法是为整个应用程序提供一个共同的背景图像。 我试图在图像中包装导航器,结果相同。React Native:是否有可能在视图中有导航器?

<View style={styles.container}> 
    <Image source={pic} style={styles.backgroundImage}></Image> 
    <Navigator 
    configureScene={this.configureScene} 
    style={styles.app} 
    initialRoute={{ component: Main }} 
    renderScene={this.renderScene} 
    /> 
</View> 
+0

我不这么认为。您可能想要将render背景图像作为renderScene的一部分来处理,但我主要是猜测。 –

+0

检查此问题http://stackoverflow.com/questions/31319947/how-to-set-a-background-image-of-navigator-in-react-native?rq=1 – Jickson

+0

谢谢@Jickson我看过它已经。但是当我这样做时,没有场景被渲染......所以我猜测新版本的RN版本已经改变了现在的做法 – sebap

回答

1

是什么让我陷入错误是,如果容器的导航器得到了align-items:center,我没有看到它。不知道为什么。但是我对这个解决方案很满意。

<Image source={pic} style={styles.backgroundImage}> 
      <Navigator 
       configureScene={this.configureScene} 
       style={styles.app} 
       initialRoute={{ component: Main }} 
       renderScene={this.renderScene} 
      /> 
      </Image> 

风格:

app: { 
    flex: 1 
    }, 
    backgroundImage: { 
    flex: 1, 
    justifyContent: 'center', 
    //alignItems: 'center' 
    } 
+0

你今天救了我,谢谢:) –

1

只需添加柔性:1到View的风格。巴达bing bada繁荣。

<View style={{ flex: 1 }}> 
    <Navigator 
    configureScene={this.configureScene} 
    style={styles.app} 
    initialRoute={{ component: Main }} 
    renderScene={this.renderScene} 
    /> 
</View> 
相关问题