Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNative禁止字体大小随着系统字体大小改变 #36

Open
ChenPt opened this issue Nov 30, 2019 · 0 comments
Open

ReactNative禁止字体大小随着系统字体大小改变 #36

ChenPt opened this issue Nov 30, 2019 · 0 comments
Labels
RN react native

Comments

@ChenPt
Copy link
Owner

ChenPt commented Nov 30, 2019

react native 原生的text标签和textInput标签的字体大小是会随着系统字号的改变而改变的。
控制这种特性的属性是allowFontScaling,默认值为true。解决办法

  1. 每一个Text标签和TextInput标签手动添加allowFontScaling: false,这样不太符合实际
  2. 再封装Text,TextInput,添加allowFontScaling: false属性
  3. 重写原生Text,TextInput的render方法,传一个allowFontScaling
  4. 如下
// 字体大小不会随着系统字体大小而变化
TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, { allowFontScaling: false })
Text.defaultProps = Object.assign({}, Text.defaultProps, { allowFontScaling: false })
@ChenPt ChenPt added the RN react native label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RN react native
Projects
None yet
Development

No branches or pull requests

1 participant