iOS 震動

2019-08-14 14:24 更新

震動 API 是在 VibrationIOS.vibrate() 里顯示的。在 iOS 上,調(diào)用這個函數(shù)可以出發(fā)一秒鐘的振動。振動是異步的,所以這個方法會立即返回。

這對不支持振動的設(shè)備是沒有任何影響的,例如,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,
  },
});


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號