【发布时间】:2018-07-08 16:26:33
【问题描述】:
如何在 react-native-camera 上添加遮罩?
我正在使用 react-native-camera 为 React Native QRCode 扫描仪应用程序构建 UI。
相机顶部的叠加蒙版应为浅灰色,但中间部分必须保持透明(透视)。
但是当我改变外罩的背景颜色时,它似乎也影响了中心部分。我的意思是,当然,它在它的子视图后面。
下面的代码是快照的简化版本。
<Camera
ref={cam => {
this.camera = cam;
}}
onBarCodeRead={this._onBarCodeRead}
style={styles.cameraView}
aspect={Camera.constants.Aspect.fill}
playSoundOnCapture
>
<View
style={{
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
backgroundColor: 'rgba(0.2, 0.2, 0.2, 0.2)',
alignItems: 'center',
justifyContent: 'space-around',
}}
>
<View
style={{
width: 300,
height: 300,
backgroundColor: 'transparent',
borderColor: 'white',
borderWidth: 1,
}}
/>
</View>
</Camera>
知道如何完成这项工作吗?
【问题讨论】:
标签: css react-native react-native-camera