【发布时间】:2016-02-19 01:32:49
【问题描述】:
我放置了一个图像作为根节点,以使其成为我的视图的背景。但似乎所有其他图像都变得不可见......
有没有办法使用内置组件将图像放置在背景之上,而不需要任何插件?
在下面的代码示例中,landing-background 用作背景,我的logo 图像可见,但只有在背景被移除时才可见。Text 显示在背景之上,没有任何问题...
<View style={styles.container}>
<Image source = {require('./img/landing-background.jpg')}
resizeMode = 'cover' style = {styles.backdrop}>
<View style = {styles.overlay}>
<Text style = {styles.headline}>It should appear in front of the Background Image</Text>
<Image style = {styles.logo} source = {require('./img/logo.png')} />
</View>
</Image>
</View>
var styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
overlay: {
opacity: 0.5,
backgroundColor: '#000000'
},
logo: {
backgroundColor: 'rgba(0,0,0,0)',
width: 160,
height: 52
},
backdrop: {
flex:1,
flexDirection: 'column'
},
headline: {
fontSize: 18,
textAlign: 'center',
backgroundColor: 'rgba(0,0,0,0)',
color: 'white'
}
});
【问题讨论】:
标签: ios image react-native