简体   繁体   English

如何在react-native-navigation中使用基于本机的图标

[英]How to use native-base icons in react-native-navigation

In my current react native app. 在我目前的反应本机应用程序中。

I am using react-native-navigation for general app navigation. 我在一般应用程序导航中使用react-native-navigation。

On the other hand, I would like to use native-base for some basic UI elements. 另一方面,我想对某些基本的UI元素使用native-base。

My question is, how do I pass a <Icon name="ios-search"/> from native-base to a react-native-navigation tab? 我的问题是,如何将<Icon name="ios-search"/>从本机库传递到react-native-navigation选项卡?

Based on this wiki. 基于此Wiki。 It seems that they only accept an actual image for a tab icon? 看来他们只接受标签图标的实际图像? https://github.com/wix/react-native-navigation/wiki/Top-Level-API https://github.com/wix/react-native-navigation/wiki/Top-Level-API

As far as i see it, native-base icons is just a wrapper on react-native-vector-icon. 据我所知,基于本地的图标只是对react-native-vector-icon的包装。 In react-native-vector-icon, there is a getImageResource function that allows me to convert icons into images. 在react-native-vector-icon中,有一个getImageResource函数,允许我将图标转换为图像。 How do I do it in native-base? 如何在本机基础上做?

getImageSource function will be added to the Icon in next version of Native Base. getImageSource函数将被添加到下一版本的Native Base中的Icon中。

For now, you can import any Icon family directly from react-native-vector-icons and use getImageSource from there. 现在,您可以直接从react-native-vector-icons导入任何Icon系列,然后从那里使用getImageSource

import Ionicons from 'react-native-vector-icons/Ionicons';
...
...

getImageSource('ios-home', 20, 'red').then((source) => this.setState({ userIcon: source }));

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM