📜  响应式字体大小反应原生 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:25.399000             🧑  作者: Mango

代码示例4
import { Dimensions, Platform, PixelRatio } from 'react-native';

const {
  width,
  height,
} = Dimensions.get('window');

export function normalize(size, multiplier = 2) {
  const scale = (width / height) * multiplier;

  const newSize = size * scale;

  return Math.round(PixelRatio.roundToNearestPixel(newSize));
}