React Native传递字体大小不变的原生操作系统小部件?



React Native传递fontSize不变到本机操作系统小部件吗?我正试图调试模拟(Figma)和实现之间的差异,并希望排除RN中发生的字体大小的任何转换。

如果你想缩放应用程序中的所有文本,你可以编写自定义scaleText()函数,它将根据(PixelRatio)当前运行的设备缩放文本。查看这篇文章了解更多信息。

如果您想禁用本机操作系统缩放TextInput或Text,您可以阅读这篇文章。

试着这样做:

index.js file
import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
import {Text, TextInput} from 'react-native';
AppRegistry.registerComponent(appName, () => App);
//ADD this
if (Text.defaultProps == null) {
Text.defaultProps = {};
Text.defaultProps.allowFontScaling = false;
}
if (TextInput.defaultProps == null) {
TextInput.defaultProps = {};
TextInput.defaultProps.allowFontScaling = false;
}

我希望它对你有帮助。

最新更新