React Native中的React导航图标

时间:2018-06-21 11:15:47

标签: javascript reactjs react-native styles mobile-development

我使用react-native-navigation在我的项目中创建导航,我需要放置图像而不是图标,这是我的代码

const startTabs = () => {
  Navigation.startTabBasedApp({
    tabs: [
      {
        screen: "awesome-places.Product",
        label: "first Icon",
        title: "first Icon",
        icon: require("../../../images/006-coffee-cup.png")
      },
      {
        screen: "awesome-places.Bag",
        label: "Icon",
        title: "Icon"
      }
    ]
  });
};

结果是蓝色的! enter image description here

但是原始图片是这样的:enter image description here

并且我需要保留图像的颜色,那么我该怎么做呢?

1 个答案:

答案 0 :(得分:0)

我认为默认情况下,每个选中的图标的背景色也会改变, “更改所有非透明像素的颜色”

尝试添加具有相同图像的 selectedIcon

const startTabs = () => {
  Navigation.startTabBasedApp({
    tabs: [
      {
        screen: "awesome-places.Product",
        label: "first Icon",
        title: "first Icon",
        icon: require("../../../images/006-coffee-cup.png")
        selectedIcon: require("../../../images/006-coffee-cup.png")

      },
      {
        screen: "awesome-places.Bag",
        label: "Icon",
        title: "Icon"
      }
    ]
  });
};