官方教程:git地址?
1砾嫉、在命令行輸入:npm install react-native-vector-icons --save
2、在項(xiàng)目中可以看到react-native-vector-icons的目錄截圖如下:
紅色框里面是已經(jīng)存在的字體窒篱,總共有9個(gè)
對(duì)應(yīng)有幾個(gè)圖標(biāo)焕刮。
3、接下來(lái)要在xcode工程目錄中加入fonts文件夾墙杯,(記住不是在xcode中右擊加入)配并,而是要拖拽進(jìn)去,然后會(huì)提示是否:"Add to targets" and that "Create groups"高镐,拖拽進(jìn)去后工程自動(dòng)會(huì)彈出提示溉旋,是否add to targets? 和create groups? 記得要打鉤,
4嫉髓、在xcode項(xiàng)目中一般會(huì)自動(dòng)增加:
如果沒(méi)有自動(dòng)增加可以打開(kāi)info.plist文件增加:
不要意思代碼貼不進(jìn)去观腊。
UIAppFonts
Entypo.ttf
EvilIcons.ttf
FontAwesome.ttf
Foundation.ttf
Ionicons.ttf
MaterialIcons.ttf
Octicons.ttf
SimpleLineIcons.ttf
Zocial.ttf
5、按照教程在react-native項(xiàng)目中引入react-native-vector-icons 算行;如:
? ? ? import Ficon from'react-native-vector-icons/FontAwesome'恕沫;
render()里面使用:<Ficon? name="對(duì)應(yīng)名字:arrow-left" size={大小:20} color="字體顏色:#fff"/>
6纱意、此時(shí)如果在項(xiàng)目中reload的話(huà)會(huì)提示FontAwesome字體不存在婶溯。記住一定要在xcode中重啟項(xiàng)目才可以使用。
? ?