ios - Xcode/Simulator 与物理设备上的 React Native 字体大小不同

标签 ios xcode react-native font-size

我一直无法让我的 React Native 应用布局在实体 iPhone 11 Pro 上看起来与在 iPhone 11 Pro 的 iOS 模拟器上看起来一样。具体来说,问题在于文本呈现。看起来两者的字体大小根本不一样。

Xcode和模拟器都是11.7版本,手机和模拟器都是iOS 13.7。 React Native 的版本是 0.61.5。

由于我无法共享整个屏幕,所以我已裁剪到相关区域。我在其中留下了部分相邻图形以指示空间的尺寸。

iPhone 11 Pro模拟器渲染图:

Simulator

iPhone 11 Pro 设备渲染:

iPhone 11 Pro

RN View :

    <View style={styles.container}>
      <Image source={require('./assets/tophalf.jpg')}
          style={{width: '100%', height: '50%'}}
          imageStyle={{resizeMode: 'contain'}} />
      <View style={styles.container2}>
      <View style={{flex:1}} />
      <View style={{flex:8}}>
          <View style={{flex:4, alignSelf:'center', width: '85%'}}>
            <Text style={styles.aboutfont}>{loremtext}</Text>
          </View>
          <View style={{flex:2}}>
            <Image source={require('./assets/blob.png')}
                  style={{flex:1, width:'50%', height:'50%', alignSelf: 'flex-end'}}
                  resizeMode="contain" />
          </View>
          <View style={{flex:1}} />
        </View>
      </View>
      <Image source={require('./assets/middlebox.png')}
        style={{position:'absolute', alignItems: 'center',
                width:100, height:100,
                borderWidth:1, borderColor:'#eeeeee', borderRadius:5,
                aspectRatio:1}}
      />
    </View>

以及样式元素:

  container: {
    flex: 1,
    backgroundColor: '#ffffff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  container2: {
    flex: 1,
    backgroundColor: 'white',
    justifyContent: 'space-around',
  },
  aboutfont: {
    fontSize: 14,
    fontFamily: Platform.OS === 'ios' ? 'Futura' : 'Roboto',
    color: 'black',
    textAlign: 'center',
  },

如有任何帮助,我们将不胜感激。我不知道这是 React Native 的具体问题还是 Xcode/Simulator 的问题。

最佳答案

我的第一直觉是,您的物理设备和模拟器上的文本大小和/或显示缩放设置可能不同。 React Native 的文本组件足够智能,可以根据用户的设置进行缩放,无论是在 iOS 还是 Android 上。

尝试检查“设置”>“显示和亮度”>“文字大小”中的值 在“设置”>“显示和亮度”>“显示缩放”>“查看”中

希望能解决您的问题!

关于ios - Xcode/Simulator 与物理设备上的 React Native 字体大小不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64126123/

相关文章:

ios - 彻底清除应用程序数据以进行干净构建?

ios - 使用 dispatch_async 或 performSelectorOnMainThread 在主线程上执行 UI 更改?

Xcode:如何使用具有跨项目引用的单独项目在您的应用程序中嵌入框架?

iphone - 滚动到索引

ios - 应用程序传输安全 Xcode 7 beta 6

node.js - React Native 不会在模拟器上本地获取

reactjs - 使用备忘录防止子组件在上下文提供程序下重新渲染

ios - Swift 包含数组的扩展

android - FabricViewStateManager : setState called without a StateWrapper

iphone - 覆盖默认的 tableview setEditing 行为