检索反应性本机导航标题的字体大小

问题描述

我是新手...

我需要检索react本机导航标题使用的字体大小,以便我可以在其他地方使用相同的字体大小。我看到了大量有关如何设置字体大小的文档。我不需要自己设置。我只需要获取字体大小,即使用的认字体即可。

我正在使用React Native Navigation 4.0。

解决方法

没有方法可以检索它,但是您可以检查视图并弄清楚它,也可以检查源代码(上帝保佑开源!)

https://github.com/react-navigation/react-navigation/blob/a484c1d7834f195ac0cfccda6a9f905218bc2274/packages/stack/src/views/Header/HeaderTitle.tsx

const styles = StyleSheet.create({
  title: Platform.select({
    ios: {
      fontSize: 17,fontWeight: '600',},android: {
      fontSize: 20,fontFamily: 'sans-serif-medium',fontWeight: 'normal',default: {
      fontSize: 18,fontWeight: '500',}),});