0

我正在使用 react-native-router-flux 并设置了导航栏。目前,导航栏的高度被设计为比默认高度更短,因此导航栏容器内的元素位置较低,靠近导航栏容器的底部。

我试过navigationBarStyle={{backgroundColor: 'pink', height: 55, flex: 1, justifyContent: 'center'}}了,但还是没有运气。

如何将导航栏中的元素垂直居中?

目前,右侧导航栏按钮Settings设置为导航到Settings组件。但是在Settings页面上,想去掉Settings右边导航栏的按钮。我该怎么做?

这是它的外观(粉红色背景的导航栏是容器,左侧的抽屉按钮、场景标题(主页)和右侧的设置按钮靠近导航栏的底部):

在此处输入图像描述

这是代码:

const RouterWithRedux = connect()(Router)
const store = configureStore()

export default class App extends Component {
  constructor() {
    super()
  }

  render() {

    return (
      <Provider store={store}>
        <RouterWithRedux>
          <Scene key='root'>
            <Scene component={Login} hideNavBar initial={true} key='login' sceneStyle={{backgroundColor: 'black'}} title='Login' type='reset'/>
            <Scene key='drawer' component={NavDrawer} open={false}>
              <Scene key="main" navigationBarStyle={{backgroundColor: 'pink', height: 55, flex: 1, justifyContent: 'center'}} onRight={() => Actions.settings()} rightTitle='Settings'>
                <Scene
                  component={Home}
                  initial={true}
                  key='home'
                  sceneStyle={{backgroundColor: 'black'}}
                  title='Home'
                  type='reset'
                />
                <Scene
                  component={Settings}
                  direction='vertical'
                  key='settings'
                  sceneStyle={{backgroundColor: 'black'}}
                  title='Settings'
                />
              </Scene>
            </Scene>
          </Scene>
        </RouterWithRedux>
      </Provider>
    )
  }
}

先感谢您

4

1 回答 1

1

你正在寻找的是align-items: 'center'

https://developer.mozilla.org/en-US/docs/Web/CSS/align-items

navStyle: { backgroundColor: 'pink', height: 55, flex: 1, flexDirection: 'row', alignItems: 'center' }

使用检查器(模拟器中的 command+d)将真正帮助您在 react-native 应用程序中调试未来的样式问题

于 2016-10-17T03:13:49.153 回答