5

do you know how to natively limit the fontSize multiplier that comes with accessibility on iOS. I saw this gist : https://gist.github.com/Jpoliachik/ed5cb38b480bc544427ce0db529786bf
But it seems outdated and I'm not good enough in Obj-C to fix it.

ArzhRo
  • 71
  • 2
  • 4

1 Answers1

22

Solution for React Native =< 0.58

iOS uses AccessibilityManager fro that (which is not available for Android) https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/IntegrationTests/AccessibilityManagerTest.js

Android requires a native (Java) solution, how to prevent system font-size changing effects to android application?

For React Native >= 0.59

Text and TextInput component have a maxFontSizeMultiplier prop. https://facebook.github.io/react-native/docs/next/text#maxfontsizemultiplier

With it, the app will be able to have a cross-platform solution to set font scale capping from JS

In your App.js:

Text.defaultProps = {};
Text.defaultProps.maxFontSizeMultiplier = 1.3;

TextInput.defaultProps = {};
TextInput.defaultProps.maxFontSizeMultiplier = 1.3;
Estevão Lucas
  • 4,440
  • 34
  • 37