导航栏配置

路由导航栏配置

更改标题

{
    Tab1: {
      screen: Tab1,
      navigationOptions: {
        title: "新闻"
      }
    },
    Tab2: {
      screen: Tab2,
      navigationOptions: {
        title: "图片"
      }
    }
  },
  {
    //设置标题栏通配效果
    navigationOptions: {
      title: "标题"
    },
    //设置文本选中前后效果颜色
    tabBarOptions: {
      activeTintColor: "white", //激活样式
      inactiveTintColor: "#FF0000" //未激活样式
    },
    tabBarPosition: "top", //设置显示位置
    swipeEnabled: false, //是否可以滑动
    animationEnabled: true //滑动效果
  }

底部图片配置(网络图片)

 {
    Tab1: {
      screen: Tab1,
      navigationOptions: {
        title: "首页"
      }
    },
    Tab2: {
      screen: Tab2,
      navigationOptions: {
        title: "我的"
      }
    }
  },
  {
    //设置选中和未选中的颜色(文字、图片、背景)
    tabBarOptions: {
      // activeTintColor: "#0000FF",
      // inactiveTintColor: "#FFFFFF"
      // activeBackgroundColor: "#FFFFFF",
      // inactiveBackgroundColor: "#0000FF"
    },

    //配置底部导航图片
    navigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused, tintColor }) => {
        const { routeName } = navigation.state;
        let iconName;
        if (routeName === "Tab1") {
          iconName = "ios-document";
        } else if (routeName === "Tab2") {
          iconName = "ios-create";
        }

        return <Ionicons name={iconName} size={25} color={tintColor} />;
      }
    })
  }

底部配置图片(本地图片)

import { createBottomTabNavigator } from "react-navigation";
import Ionicons from "react-native-vector-icons/Ionicons";
import React from "react";
import { Image } from "react-native";
import Home from "./Home";
import Cai from "./Cai";
const Route = createBottomTabNavigator(
  {
    Home: {
      screen: Home,
      navigationOptions: {
        title: "首页",
        header: null
      }
    },
    Cai: {
      screen: Cai,
      navigationOptions: {
        title: "财富",
        header: null
      }
    }
  },
  {
    backBehavior: "none",
    tabBarOptions: {
      activeTintColor: "#5599ff",
      style: {
        backgroundColor: "#f8f8f8"
      },
      indicatorStyle: {
        opacity: 0
      },
      tabStyle: {
        padding: 0
      },
      labelStyle: {
        fontSize: 12
      }
    },
    navigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused, tintColor }) => {
        const { routeName } = navigation.state;
        if (routeName === "Home") {
          if (focused) {
            return (
              <Image
                style={{ width: 27, height: 27 }}
                source={require("../zf/a1.png")}
              />
            );
          } else {
            return (
              <Image
                style={{ width: 27, height: 27 }}
                source={require("../zf/a2.png")}
              />
            );
          }
        } else if (routeName === "Cai") {
          if (focused) {
            return (
              <Image
                style={{ width: 23, height: 23 }}
                source={require("../zf/b2.png")}
              />
            );
          } else {
            return (
              <Image
                style={{ width: 23, height: 23 }}
                source={require("../zf/b1.png")}
              />
            );
          }
        }
      }
    })
  }
);

export default Route;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值