【问题标题】:Show both title and image in navigation bar: react-native-router-flux在导航栏中显示标题和图像:react-native-router-flux
【发布时间】:2019-01-31 11:39:56
【问题描述】:

我想在导航栏中显示图像和标题,但使用下面的代码我一次只能实现一个。

下面的代码只显示图像和汉堡图标

<Drawer
      hideNavBar
      key="drawerMenu"
      contentComponent={SideMenu}
      drawerWidth={250}
      drawerPosition="left">

      <Scene key="dashboard"
             component={Home}
             navigationBarTitleImage = {require('./images/logo.jpeg')}
             navigationBarTitleImageStyle = {{width:30, height:30}}
             title={"Dashboard"}/>
</Drawer>

输出:

现在,当我注释掉 navigationBarTitleImage 时,只有标题可见,请检查下面的代码和输出

<Drawer
    hideNavBar
    key="drawerMenu"
    contentComponent={SideMenu}
    drawerWidth={250}
    drawerPosition="left">
          <Scene key="dashboard"
                 component={Home}
                 //navigationBarTitleImage = {require('./images/logo.jpeg')}
                 //navigationBarTitleImageStyle = {{width:30, height:30}}
                 title={"Dashboard"}/>

    </Drawer>

输出:

我总共想要三样东西:抽屉图标、自定义图标以及标题。谁能告诉我我的代码有什么问题?

【问题讨论】:

  • 我强烈推荐你使用 react-native-elements 中的 Header 组件,它真的很容易定制,你也可以轻松定义你希望标题出现的屏幕
  • 能否请您推荐标题组件使用的链接/快照?

标签: react-native react-native-router-flux


【解决方案1】:

只需使用navBar 属性。它允许你渲染任何你想要的东西。

docs

【讨论】:

    猜你喜欢
    • 2017-03-14
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多