简体   繁体   English

如何使用“@react-navigation/bottom-tabs”在 Tab.Screen 左侧添加 header

[英]How to add header left on Tab.Screen using "@react-navigation/bottom-tabs"

I'm using @react-navigation/bottom-tabs Package but I don't understand how to add header left on Tab.Screen tag?我正在使用@react-navigation/bottom-tabs Package 但我不明白如何在 Tab.Screen 标签上添加 header?

And also can I add image on header left?我还可以在 header 左边添加图像吗?

Here is my code:这是我的代码:

import React from "react";
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Home from "./TabScreen/Home";
import Category from "./TabScreen/Category";
import Search from "./TabScreen/Search";
import Profile from "./TabScreen/Profile";
import Colors from "../../../Style_Sheet/Colors";

const Tab = createBottomTabNavigator();

const Tabs =()=>{
  return(
    <Tab.Navigator tabBarPosition="bottom" screenOptions={{
      tabBarStyle: {
        backgroundColor: Colors.dark,
      },
    }}>
      <Tab.Screen name="Home" component={Home} options={{headerTitle:"Explore",headerTintColor:Colors.white,headerStyle:{backgroundColor:Colors.dark}}}/>
      <Tab.Screen name="Category" component={Category} options={{headerTitle:"",headerTintColor:Colors.white,headerStyle:{backgroundColor:Colors.dark},headerLeft:{}}}/>
      <Tab.Screen name="Search" component={Search} options={{headerTitle:"Explore",headerTintColor:Colors.white,headerStyle:{backgroundColor:Colors.dark}}}/>
      <Tab.Screen name="Profile" component={Profile} options={{headerTitle:"Explore",headerTintColor:Colors.white,headerStyle:{backgroundColor:Colors.dark}}}/>
    </Tab.Navigator>
  )
}
export default Tabs;

Use this,用这个,

Here is the code where you can add the headerLeft on Tabs.Screen tag.这是您可以在 Tabs.Screen 标记上添加 headerLeft 的代码。

<Tabs.Screen
    name="Home"
    component={HomeScreen}
    options={{
      headerTitle: props => <LogoTitle {...props} />,
      headerLeft: () => (
        <Button
          onPress={() => alert('This is a button!')}
          title="Info"
          color="#fff"
        />
      ),
    }}
  />

and also you can add image or Button under the headerLeft Tag, for more details follow this link您也可以在 headerLeft 标签下添加图像或按钮,有关更多详细信息,请点击此链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用时如何从底部标签栏隐藏“SPECIFIC TAB BAR ITEM”:@react-navigation/bottom-tabs - How to hide a "SPECIFIC TAB BAR ITEM" from a bottom tab bar when using: @react-navigation/bottom-tabs 如何在反应导航 5.x 中从选项卡导航(底部选项卡)中隐藏 header? - How to hide the header from Tab navigation (bottom-tabs) in react navigation 5.x? Redux和react-navigation底部选项卡组件 - Redux and react-navigation bottom-tabs component 它已更新,但它说请更新 @react-navigation/bottom-tabs、@react-navigation/stack 和 @react-navigation/drawer 到 5.10.0 或更高版本 - It is updated but it say Pleaseupdate @react-navigation/bottom-tabs, @react-navigation/stack and @react-navigation/drawer to version 5.10.0 or above 如何隐藏特定屏幕上的底部标签栏(react-navigation 3.x) - How can I hide the bottom tab bar on a specific screen (react-navigation 3.x) 使用 React-Navigation 底部选项卡的交叉淡入淡出过渡 - Cross-Fade transitions using React-Navigation bottom Tab 如何在底部选项卡导航器 react-navigation 中卸载非活动屏幕? - How to unmount inactive screens in bottom tab navigator react-navigation? 如何在 React Native 中创建子 Tab.Screen? - How to create a child Tab.Screen in React Native? 如何使用反应导航从标题中的按钮“导航”到新屏幕? - How to `navigate` to new screen from button in header with react-navigation? 如何做 React-Navigation 路由? (标签) - How to do a React-Navigation Route? (Tabs)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM