解决方法:
去 node_modules/react-navigation/src/views/Header/Header.js中的 title 属性一栏里
_renderTitle(props, options) {
const { layoutPreset, transitionPreset } = this.props;
let style = [
{ justifyContent: layoutPreset === 'center' ? 'center' : 'flex-start' },
getTitleOffsets(
layoutPreset,
false,
options.hasLeftComponent,
options.hasRightComponent
),
options.headerTitleContainerStyle,
];
return this._renderSubView(
{ ...props, style },
'title',
this._renderTitleComponent,
transitionPreset === 'uikit'
? this.props.titleFromLeftInterpolator
: this.props.titleInterpolator
);
}
修改为:
_renderTitle(props, options) {
const { layoutPreset, transitionPreset } = this.props;
// 主要把 flex-start 改成 center
let style = [
{ justifyContent: layoutPreset === 'center' ? 'center' : 'center' },
getTitleOffsets(
layoutPreset,
false,
options.hasLeftComponent,
options.hasRightComponent
),
options.headerTitleContainerStyle,
];
return this._renderSubView(
{ ...props, style },
'title',
this._renderTitleComponent,
transitionPreset === 'uikit'
? this.props.titleFromLeftInterpolator
: this.props.titleInterpolator
);
}