React-Native 图像不透明度赋予文本不透明度

标签 react-native react-native-ios

我使用图像基本上作为 View 并将文本放入其中,我尝试为图像提供不透明度,但每次我尝试文本也变得不透明,我真的不知道为什么会发生

enter image description here

<View style={{flex: 1}}>
  <View style={{height: 180,}}>
     <Image source={{uri : this.state.fullURLImage}} style={{flex: 1,width: window.width,justifyContent:'center',alignItems:'center',opacity: 0.7}}>
       <Text style={{textAlign: 'center',fontWeight: 'bold',color:'white',fontSize:16,}}>{this.state.title}</Text>
       <Text style={{color:'white',fontSize:14,}}>{'\n'}July {this._try(this.state.day)} | {this.state.time_start} - {this.state.time_end}</Text>
     </Image>
  </View>

  <View style={{flexGrow: 1, backgroundColor: 'white',}}>
     <Text style={{textAlign:'center',color:'#1B3D6C',fontWeight:'bold',margin:10,marginTop: 40}}>{this.state.author}</Text>
     <Text style={{margin:10,textAlign: (Platform.OS === 'ios') ? 'justify' : 'left'}}>{this.state.text}</Text>

  </View>
  <Image
     source={{uri : this.state.fullURLAuthor}}
     style={{
        position: 'absolute',
        top: 180 - 64 / 2,
        height: 64,
        width: 64,
        left: (Dimensions.get('window').width - 64) / 2,
        borderRadius: 32,
     }}
  />
</View>

最佳答案

您需要将文本放在图像标签之外并指定它们的位置

或者

还可以使用 {backgroundColor: 'rgba(0,0,0,0.5)'}} 提供不透明度

关于React-Native 图像不透明度赋予文本不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44053014/

相关文章:

javascript - 不是导入函数的函数错误

javascript - React Native 0.44 PushNotifcationIOS.scheduleLocalNotification 在模拟器中处理 JavaScript Date 对象,而不是在设备上

react-native - 我如何在 React Native Accessibility 中制作 TouchableHightLight(复选框)?

android - 如何在 Android 端动画加载 GIF?

ios - 在没有 iTunes 的情况下安装 .ipa 文件?

javascript - 尝试通过 Expo (React Native) 启动应用程序时从 NodeJS 获取 EISDIR 错误

reactjs - 自动预测在 iOS 13 中无法使用 textContentType 到 TextInput

react-native - 与react-native run-ios独占的不变违规

react-native - 一段时间后锁定 React Native 应用程序

react-native - 无效的 native 权限 ios.PERMISSION.CAMERA