【问题标题】:Icon not showing in searchbar in iOSiOS的搜索栏中未显示图标
【发布时间】:2019-09-25 09:52:27
【问题描述】:

我只在我的搜索图标所在的位置看到了一个问号图标。还为我的其他字体获取无法识别的字体。

  <SearchBar
                round
                containerStyle={{
                    borderTopWidth: 0,
                    borderBottomWidth: 0
                }}
                inputStyle={{ backgroundColor: "white" }}
                inputContainerStyle={{
                    borderRadius: 5,
                    backgroundColor: "white"
                }}
                icon={{
                    type: "fontAwesome",
                    color: "#86939e",
                    name: "fa-search"
                }}
                onSubmitEditing={this.onSubmitEdit}
                searchIcon={{ size: 18 }}
                onChangeText={text => this.SearchFilterFunction(text)}
                onClear={text => this.SearchFilterFunction("")}
                placeholder="Type Here..."
                value={term}
            />

除了我的 serahc 图标没有出现,我无法让我的字体显示使用:

  menuText: {
    fontSize: 15,
    color: "#fff",
    opacity: 1,
    fontFamily: "lato-regular",
    textTransform: "uppercase"
  }

我已经链接了包,并将字体文件复制到xcode中。

我所有的字体都出现在 xcode 中的Resources 下。如何显示我的图标?

我在 info.plist 中有我的字体:

<key>UIAppFonts</key>
<array>
    <string>Lato-Regular.ttf</string>
    <string>Lato-Light.ttf</string>
    <string>FontAwesome.ttf</string>
    <string>Lato-Bold.ttf</string>
    <string>MaterialIcons.ttf</string>
    <string>Lato-Black.ttf</string>
    <string>Lato-BlackItalic.ttf</string>
    <string>Lato-BoldItalic.ttf</string>
    <string>Lato-Hairline.ttf</string>
    <string>Lato-HairlineItalic.ttf</string>
    <string>Lato-Heavy.ttf</string>
    <string>Lato-HeavyItalic.ttf</string>
    <string>Lato-Italic.ttf</string>
    <string>Lato-LightItalic.ttf</string>
    <string>Lato-Medium.ttf</string>
    <string>Lato-MediumItalic.ttf</string>
    <string>Lato-Semibold.ttf</string>
    <string>Lato-SemiboldItalic.ttf</string>
    <string>Lato-Thin.ttf</string>
    <string>Lato-ThinItalic.ttf</string>
    <string>SpaceMono-Regular.ttf</string>
</array>

【问题讨论】:

    标签: react-native react-native-vector-icons


    【解决方案1】:

    试试这个:-

    import Icon from 'react-native-vector-icons/FontAwesome';
    const myIcon = <Icon name="rocket" size={30} color="#900" />;
    

    在您的代码中使用 myIcon。

    【讨论】:

    • 我无法显示任何字体,我已经编辑了我的原始帖子
    【解决方案2】:

    如果您使用的是 react-native-vector-icons,请查看此https://oblador.github.io/react-native-vector-icons/ 以查找您的图标

    名字不是fa-search,只是search

    【讨论】:

    • 仍然无法正常工作,我已经编辑了我的问题并提供了更多详细信息
    猜你喜欢
    • 2022-01-24
    • 1970-01-01
    • 2018-05-10
    • 1970-01-01
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    相关资源
    最近更新 更多