React Native:iOS 震动

震动 API 是在 VibrationIOS.vibrate() 里显示的。在 iOS 上,调用这个函数可以出发一秒钟的振动。振动是异步的,所以这个方法会立即返回。

这对不支持振动的设备是没有任何影响的,例如,iOS 模拟器。

目前是不支持振动模式的。

方法

static vibrate()

例子

Edit on GitHub

use strict;var React = require(react-native);var {
  StyleSheet,
  View,
  Text,
  TouchableHighlight,
  VibrationIOS
} = React;
exports.framework = React;
exports.title = VibrationIOS;
exports.description = Vibration API for iOS;
exports.examples = [{
  title: VibrationIOS.vibrate(),
  render() {    return (      <TouchableHighlight
        style={styles.wrapper}
        onPress={() => VibrationIOS.vibrate()}>        <View style={styles.button}>
          <Text>Vibrate</Text>
        </View>
      </TouchableHighlight>
    );
  },
}];var styles = StyleSheet.create({
  wrapper: {
    borderRadius: 5,
    marginBottom: 5,
  },
  button: {
    backgroundColor: #eeeeee,
    padding: 10,
  },
});

作者:andy,如若转载,请注明出处:https://www.web176.com/reactnative/22023.html

(0)
打赏 支付宝 支付宝 微信 微信
andy的头像andy
上一篇 2023年5月19日
下一篇 2023年5月19日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注