Che*_*ana 9 react-native native-base
我按照NativeBase Docs中的设置说明运行rnpm link.我收到此错误:
无法识别的字体系列ionicons
也由Xcode检查,字体已经处于构建阶段.我错过了什么?
小智 13
对于RN 0.60+,请不要使用react-native link ...!(请参阅自动链接)
而是将其添加到您的Podfile:
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
Run Code Online (Sandbox Code Playgroud)
然后运行pod update(或pod install)。
此外,将此添加到您的Info.plist:
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
</array>
Run Code Online (Sandbox Code Playgroud)
(取自https://github.com/oblador/react-native-vector-icons#option-with-cocoapods)
在我的项目中可以正常工作:
"react": "16.9.0",
"react-native": "0.61.1",
"native-base": "2.13.8" (react-native-vector-icons@6.6.0),
Run Code Online (Sandbox Code Playgroud)
小智 7
使用Icon.loadFont()方法加载字体。
示例(添加您的 App.tsx):
import AntDesign from 'react-native-vector-icons/AntDesign';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Feather from 'react-native-vector-icons/Feather';
AntDesign.loadFont().then();
Ionicons.loadFont().then();
Feather.loadFont().then();
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 0.60 及更高版本,则需要执行以下步骤:-
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
</array>
Run Code Online (Sandbox Code Playgroud)
并在此之后运行以下命令:-
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Run Code Online (Sandbox Code Playgroud)
清洁和构建后。运行 ios 应用程序。这个解决方案对我有用:)
| 归档时间: |
|
| 查看次数: |
9945 次 |
| 最近记录: |