在React Native iOS的图像顶部渲染透明背景文本框

在我的React Native测试中,我试图在图像的顶部渲染一个带有白色文本的块。但是,我的图像顶部有一个黑色块,其中有白色文字。不是我预期的如何渲染具有透明背景的文本块?

当前结果

渲染功能

render: function(){
  return (
    <View style={styles.container}>
      <Image 
        style={styles.backdrop} 
        source={{uri: 'https://unsplash.com/photos/JWimshWiF14/download'}}>
          <Text style={styles.headline}>Headline</Text>
      </Image>
    </View>
  );
)

样式表功能

var styles = StyleSheet.create({
  container: {
    flex: 1,justifyContent: 'flex-start',alignItems: 'center',backgroundColor: '#000000',width: 320
  },backdrop: {
    paddingTop: 60,width: 320,height: 120
  },headline: {
    fontSize: 20,textAlign: 'center',backgroundColor: 'rgba(0,0)',color: 'white'
  }
});
您可以通过在图像中添加视图来完成此操作:
render: function(){
  return (
    <View style={styles.container}>
      <Image 
        style={styles.backdrop} 
        source={{uri: 'https://unsplash.com/photos/JWimshWiF14/download'}}>
          <View style={styles.backdropView}>
            <Text style={styles.headline}>Headline</Text>
          </View>
      </Image>
    </View>
  );
)

样式表功能

var styles = StyleSheet.create({
  container: {
    flex: 1,backdropView: {
    height: 120,},color: 'white'
  }
});

相关文章

一、前言 在组件方面react和Vue一样的,核心思想玩的就是组件...
前言: 前段时间学习完react后,刚好就接到公司一个react项目...
前言: 最近收到组长通知我们项目组后面新开的项目准备统一技...
react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...