react-native-signature 签名使用

react-native-signature 签名使用_第1张图片
1.安装react-native-signature

yarn add react-native-signature

2.使用react-native-signature

import SignatureView from "react-native-signature";

SignatureView: {
    screen: SignatureView,
    navigationOptions: {
        headerStyle: { backgroundColor: '#efeff4' },
        headerBackTitle: null,
        headerTintColor: "#333333",
        showIcon: true
    }
}
// 使用跳转路由方法
onPress={() =>  this.props.navigation.navigate('SignatureView', {
    key: 'SignatureView',
    routeName: 'SignatureView',
    title: "签字",
    callback: (data) => {
        this.setState({
            signature: data
        });
    }
})}


3.设置react-native-orientation

react-native-orientation为横屏插件
android\build.gradle文件

dependencies {
  ...
  compile project(':react-native-orientation')  //添加
  ...

}


android\app\src\main\java\com\项目名\MainApplication.java文件

import com.github.yamill.orientation.OrientationPackage;

@Override
protected List getPackages() {
  return Arrays.asList(
      ...
      new OrientationPackage(),
      ...
  );
};

android\settings.gradle文件

include ':react-native-orientation', ':app'
project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-signature/node_modules/react-native-orientation/android')

参考github链接

你可能感兴趣的:(react-native,react-native)