如何在笨拙的createStackNavigator屏幕上居中标题文本?

时间:2019-04-04 17:43:32

标签: react-native react-navigation

我试图将我的React Native应用程序的标题中的文本居中,但是我无法将文本居中放置在一个笨拙的屏幕上。对于普通的屏幕,我有这个:

const ReferralStack = createStackNavigator({
  Referrals: ReferralScreen,
  otherstuff: stuff,
},
{
  headerMode: headerMode,
  headerBackTitleVisible: false,
  headerLayoutPreset: 'center',
    navigationOptions: {
      title: 'Referrals',
      headerTransparent: true,
      headerTitleStyle: headerLabelStyle,
    headerStyle: headerStyle,
  }
});

这将使引荐屏幕的标题居中。使文本居中的代码行是 headerLayoutPreset:'center'。当应用于此其他堆栈时,它将不起作用:

const SettingsStack = createStackNavigator({
  Settings: {
    screen: SettingsScreen,
    headerMode: headerMode,
    headerBackTitleVisible: true,
    mode: 'modal',
  },
  EditEmail: {
    screen: EditEmailScreen,
    headerMode: . . .
    etc...
  }
});

const MoreStack = createStackNavigator({
  More: {
    screen: MoreScreen,
    mode: 'modal',
    headerMode: headerMode,
    headerBackTitleVisible: false,
    headerLayout: 'center',
      navigationOptions: {
        title: 'Menu',
        headerTransparent: true,
        headerTitleStyle: headerLabelStyle,
        headerStyle: headerStyle,
    }
  },
  SettingsStack
});

此屏幕的设置与上一屏幕完全不同。据我所知, headerLayout:'center'代码没有任何作用。

如何在此MoreStack屏幕的标题文本居中?

0 个答案:

没有答案