如何在 React Native for IOS 应用程序中禁用字体缩放?

如何在 React Native for IOS 应用程序中禁用字体缩放?

问题描述:

设备字体大小的放大有时会中断(样式方面).

Enlargement of size of the device font will sometimes break (Styling wise).

For React native 0.58+

For React native 0.58+

最好保持字体缩放,但您可以使用 Text new prop 限制它 maxFontSizeMultiplier

Preferable to keep font scaling but you can limit it by using Text new prop maxFontSizeMultiplier

对于 React Native 0.56+ 使用 Levi's answer

For React native 0.56+ use Levi's answer

Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;

对于 React Native 0.55 及更低版本

For React native 0.55 and lower

在应用程序的开头(例如 main.js 或 app.js 等...)添加 Text.defaultProps.allowFontScaling=false 以在整个应用程序的所有 Text 组件上应用此属性应用程序.

Add Text.defaultProps.allowFontScaling=false at the beginning of the app (e.g. main.js or app.js etc ...) to apply this prop on all Text components through out the whole app.