如何在react-native 摄像头上添加遮罩?
我正在使用React Native camera为React Native QRCode scanner应用程序构建UI.
相机顶部的叠加遮罩应为浅灰色,但中间部分必须保持透明(透明).
但当我改变外面具的背景色时,它似乎也会影响中心部分.我的意思是,当然,这是在它的 children 观背后.
下面的代码是快照的简化版本.
<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>
知道怎么做吗?