react native項目中常常會用到icon,react-native-vector-icons
字體庫解決了一部分icon的需求,可是還有一部分設計師給的icon須要在iconfont自行引用,關於使用react-native-vector-icons
遇到的坑在以前的文章提到過react native新建項目踩坑記錄(字體問題詳見問題五),主要是兩點:react
react-native-vector-icons
庫react-native unlink react-native-vector-icons
Info.plist
文件添加字體映射,詳見<key>UIAppFonts</key>
的值iconfont.ttf
的字體文件。assets/fonts
目錄,複製解壓後的t打開package.json文件,配置字體路徑:android
"rnpm": { "assets": [ "./src/assets/fonts/" ] }
react-native-vector-icons
字體庫的,這裏你link後運行項目確定報錯了,須要重複開頭的兩個步驟),link後android/app/src/main/assets/fonts目錄
添加完去rn項目下ios路徑下的Info.plist
文件查看字體完整配置:ios
<key>UIAppFonts</key> <array> <string>iconfont.ttf</string> <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>Fontisto.ttf</string> <string>Foundation.ttf</string> <string>Ionicons.ttf</string> <string>MaterialCommunityIcons.ttf</string> <string>MaterialIcons.ttf</string> <string>Octicons.ttf</string> <string>SimpleLineIcons.ttf</string> <string>Zocial.ttf</string> </array>
unicode
顯示字體待補充...npm