下载 react-native-vector-icons
npm i react-native-vector-icons
Android配置
在android/app/build.gradle这里加入下面的代码
project.ext.vectoricons = [
iconFontNames: [ 'FontAwesome.ttf', 'Feather.ttf'] // Specify font files
]
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
使用
// FontAwesome的图标
import FontAwesome from 'react-native-vector-icons/FontAwesome'
// Feather的图标
import Feather from 'react-native-vector-icons/Feather'
// 使用
const Feed = () => (
<View>
<Text>我是Feed</Text>
<FontAwesome name='music' size={16} />
<Feather name='zap' size={50} />
</View>
)