![](https://i-blog.csdnimg.cn/blog_migrate/8901590b66a53688452c837fb6f779df.png)
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<ReactPackage> getPackages() {
return Arrays.<ReactPackage>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链接