【问题标题】:How can I add a border frame in the camera?如何在相机中添加边框?
【发布时间】:2017-08-05 05:53:17
【问题描述】:

我需要在 react native 相机视图的取景器中间添加一个方框。存储库中也没有关于它的信息。而且那里的问题也没有得到回答。

【问题讨论】:

    标签: react-native-camera


    【解决方案1】:

    您正在使用哪个模块? react-native-camerareact-native-camera-kit?

    如果您使用react-native-camera,只需将View(或Image)放在Camera 组件中,然后添加样式以垂直和水平对齐此视图。

    像这样:

    const styles = {
        container: {
            flex: 1,
        },
    
        camera: {
            flex: 1,
            // These below are most important, they center your border view in container
            // ref: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
            alignItems: "center",
            justifyContent: "center"
        },
    
        borderImage: {
            // Your styles for image, or custom borders
        },
    }
    
    
    class Component extends React.Component {
    
       ...
    
        render(){
            return <View style={styles.container}>
               <Camera style={styles.camera}>
                  <Image style={styles.borderImage} source={require("./img/qrBorder.png")} />
               </Camera>
            </View>;
         }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-16
      • 2017-11-20
      • 1970-01-01
      相关资源
      最近更新 更多