react-native-vector-icons 是在看 React Native 所看到的
这个套件自带了十多种图示库,也可以将自定义图示稍微做处理後在 React Native 中使用
原本以为只需要 npm i 就可以完成... 但其实没有那麽简单!!!
还需要做一些原生的配置~~
就跟着卡卡看下去吧!
npm install react-native-vector-icons --save
react-native link react-native-vector-icons
cd ios
pod install
npm run ios
执行 react-native link 命令後你会发现在 Android 目录下这个库已经自动为我们把字体文件引入到 app/src/main 中并创建了 assets/fonts 的目录
在 android/app/build.gradle 文件中添加
// 自定义的字体文件需要在这里赋值声明,如果有多个都需要添加到数组中
project.ext.vectoricons = [
iconFontNames: [ 'iconfont.ttf' ]
]
// 如果只是使用react-native-vector-icons中的图标,只添加下面这行就行了,上面那段配置可以不写
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
import Icon from 'react-native-vector-icons/{字体}';
// 例如 FontAwesome
import Icon from 'react-native-vector-icons/FontAwesome';
<Icon name={'angle-right'} size={24} color={'#999'} />
name : icon
size : 大小
color: 颜色
name 的部分可以参照这个 doc
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import Icon from 'react-native-vector-icons/Ionicons';
<FontAwesomeIcon name={'angle-right'} size={24} color={'pink'}/>
<Icon name={'ios-sad'} size={100} color={'pink'}/>
import Icon from 'react-native-vector-icons/FontAwesome';
<Icon.Button name="star" backgroundColor="pink" onPress={function}>
go to find kaka
</Icon.Button>
参考文件:
ReactNative 乾货分享
Day 20 done ~~~ 请多多指教!
>>: [Day20] 与问题成员对话-案例二:水涨船高的 Scrum Master 接班人
昨天教的字串格式化你有没有学会了呢╰(*°▽°*)╯,还没学会的在等什麽,快回去复习呀!!!在此附上...
587. Erect the Fence https://leetcode.com/problems...
承前文,在事件的注册/绑定与监听中,入门者最常使用「监听CLICK事件」等侵入/非侵入式JavaSc...
依赖介面而不是特定的 Service 昨天我们介绍了怎麽在 .NET Web API 的专案里实现依...
Django的Template(样板) 在Django专案刚建立的时候, 我们可以从views.py...