react-native-gstyle
v2.0.4
Published
rn适配屏幕字体
Readme
react-native-gstyle
适合大部分手机兼容,如有不兼容,请反馈!
安装
npm i react-native-gstyle
使用
import Gstyle from 'react-native-gstyle';
index.js 文件 //需要在程序入口处导入
- 默认设计稿 width = 375 height = 667
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
return (
<Fragment>
<View style={{ width: Gstyle.scale(66), height: Gstyle.scale(66), borderWidth: Gstyle.scale(1) }}>
<Text style={{ fontSize: Gstyle.text(16) }}>世界你好!</Text>
</View>
<View style={{ width: this.scale(66), height: this.scale(66), borderWidth: this.scale(1) }}>
<Text style={{ fontSize: this.text(16) }}>世界你好!</Text>
</View>
<View style={styles.box}>
<Text style={styles.font}>世界你好!</Text>
</View>
</Fragment>
);
}
}