简体   繁体   English

底部标签导航器背景图像

[英]Bottom Tab Navigator background image

Im using React Navigation 3 .我正在使用React Navigation 3 Currently I have a bottomTabNavigator in my project.目前,我的项目中有一个bottomTabNavigator I want to set a background image or art for it.我想为它设置背景图片或艺术。 My header was pretty much straight forward because I used a property called headerBackground and I passed a react component to it and it works, but its not the case for bottomTab.我的标题非常简单,因为我使用了一个名为headerBackground的属性,并且我向它传递了一个 react 组件并且它可以工作,但对于 bottomTab 则不是这种情况。

I managed to make it work somehow by using tabBarComponent so the image renders ok, but the problem is that my tabs disappear.我设法通过使用tabBarComponent使其以某种方式工作,因此图像呈现正常,但问题是我的选项卡消失了。

Is there a proper way to set a background image to tabNavigator ?是否有将背景图像设置为tabNavigator的正确方法?

Here is my current tabNavigator code:这是我当前的tabNavigator代码:

 import React from 'react'; import { createBottomTabNavigator, createAppContainer } from 'react-navigation'; import Profile from "../components/Profile"; import { Image, View } from 'react-native'; const Tab = createBottomTabNavigator( { Profile: { screen: Profile, navigationOptions: { title: 'Home', tabBarIcon: ({ tintColor }) => ( <Image source={require('../../images/home-ico.png')} style={{width: 25, height: 25, resizeMode: 'contain'}} /> ) } }, Partidos: { screen: Profile, navigationOptions: { title: 'Home', tabBarIcon: ({ tintColor }) => ( <Image source={require('../../images/home-ico.png')} style={{width: 25, height: 25, resizeMode: 'contain'}} /> ) } }, Grupos: { screen: Profile, navigationOptions: { title: 'Home', tabBarIcon: ({ tintColor }) => ( <Image source={require('../../images/home-ico.png')} style={{width: 25, height: 25, resizeMode: 'contain'}} /> ) } }, Reserva: { screen: Profile, navigationOptions: { title: 'Home', tabBarIcon: ({ tintColor }) => ( <Image source={require('../../images/home-ico.png')} style={{width: 25, height: 25, resizeMode: 'contain'}} /> ) } } }, { tabBarOptions:{ style: { backgroundColor: '#c2b464', }, showLabel: false }, tabBarComponent: props =>{ return( <View> <Image style={{ width: '100%', height: 50 }} source={ require('../../images/tabs-bg.png')}/> </View> ); } } ); export default createAppContainer(Tab);

tabBarComponent: props =><BottomNavigator {...props}/>

Just make the component and create the Icon or Text in and render it.只需制作组件并在其中创建图标或文本并渲染它。 Under component u can navigate to other screen by this.props.navigation.navigate('desirescreen-route');在组件下你可以通过this.props.navigation.navigate('desirescreen-route');导航到其他屏幕this.props.navigation.navigate('desirescreen-route');

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

相关问题 在 React native 中创建自定义底部选项卡导航器 - Create custom bottom tab navigator in React native 如何创建具有多行的底部标签导航器? - How to create a bottom tab navigator with multiple rows? 如何设置 Tab.Navigator 的背景颜色? - How to set the background color of Tab.Navigator? Expo Android 从底部标签导航器切换到材料顶部标签导航器时有白色闪烁 - Expo Android there is a white flicker when switching from bottom tab navigator to material top tab navigator 如何将多个导航器相互嵌套? 即在抽屉导航器中嵌套底部选项卡并将抽屉导航器嵌套到堆栈导航器 - How to nest multiple navigator within each other? i.e. nesting bottom tab in drawer navigator and nesting drawer navigator to stack navigator 如何在底部选项卡导航器 react-navigation 中卸载非活动屏幕? - How to unmount inactive screens in bottom tab navigator react-navigation? 如何在底部选项卡导航器中删除顶部栏(主页) - How to remove top bar (Home) in Bottom Tab Navigator React Navigation V5 在 Stack Navigator 中隐藏底部标签栏 - React Navigation V5 hide Bottom tab bar in Stack Navigator 如何在堆栈导航器中嵌套底部标签栏? - How can I nest a Bottom Tab Bar inside a stack Navigator? 刷新控件不适用于本机反应中的底部选项卡导航器 - Refresh Control not working with bottom tab navigator in react native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM