react native 震动 Vibration 使用详解
来源:互联网 发布:iphone se 知乎 编辑:程序博客网 时间:2024/05/22 05:13
Vibration.vibrate()用于控制设备震动。
vibrate(pattern, repeat)
pattern:参数为一个不定长的数组。在Andriod上,数组第一个元素表示开始震动前的等待时间,然后是震动持续时长和等待时长的交替,例如[0, 500, 1000, 500]表示立刻开始震动500ms,然后等待1000ms,再震动500ms;但在iOS上震动时长是固定的,所以从数组第二个元素开始都是表示震动的间隔时长。
repeat参数为布尔类型,表示是否持续循环震动。为true时只有调用cancel才会停止。
cancel :停止震动
<View style={{flex: 1}}> <Button title='震动' onPress={()=>{Vibration.vibrate([0, 500, 1000, 500],true)}}/> <Button title='取消' onPress={()=>{Vibration.cancel()}}/> </View>
更多Demo github下载地址
阅读全文
0 0
- react native 震动 Vibration 使用详解
- react-native Vibration
- react native ActivityIndicator使用详解
- react native Button 使用详解
- react native Text 使用详解
- react native Switch使用详解
- react native ScrollView 使用详解
- react native FlatList 使用详解
- react native SectionList 使用详解
- react native TextInput 使用详解
- react native Slider 使用详解
- react native StatusBar 使用详解
- react native DatePickerIOS 使用详解
- react native DrawerLayoutAndroid 使用详解
- react native Image 使用详解
- react native Modal 使用详解
- react native Picker 使用详解
- react native ProgressBarAndroid 使用详解
- odoo 定时任务的使用方法
- 视频目标检测--Flow-Guided Feature Aggregation for Video Object Detection
- 【云计算的1024种玩法】自己搭游戏服务器:我的世界Minecraft
- WPF实现窗体最小化后小图标在右边任务栏下
- C++之将与参数无关的代码抽离templates(44)---《Effective C++》
- react native 震动 Vibration 使用详解
- DSP28335官方例程Control Suit(1)——LED实验
- java基础复习--复习总结11
- C++位运算
- Idea for Mac 快捷键
- css学习笔记之水平居中
- HDU6069 Counting Divisors 区间素数筛法
- Java基础一:关键字、标示符、变量、常量和数据类型转换
- 微信sdk使用