发布于 2015-10-01 09:14:18 | 265 次阅读 | 评论: 0 | 来源: 网络整理

震动 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,
  },
});
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务