我试图将我的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屏幕的标题文本居中?