最近react native 项目遇到当改变手机的系统字体大小,项目的字体大小也会跟着影响,为了使项目字体大小不受系统设置的字体大小影响,想出了以下办法,allowFontScaling:false 禁止字体缩放 import React from 'react' import { Text, TextInput } from 'react-native' import {Input} from 'teaset' var render = Text.prototype.render // 重写render方法 Text.prototype.render = function() { let text = render.apply(this, arguments); return React.cloneElement(text, { allowFontScaling: false }) } // 解决TextINput的 placeholder的字体会跟着系统设置变化 Input.defaultProps.allowFontScaling = false;
转载于:https://my.oschina.net/caiyue/blog/1836373