 
 使用 SwitchIOS 在 iOS 上呈现出布尔型的输入。这是一个控件组件,所以为了更新组件,你必须使用 onValueChange回调并且更新值value。否则的话用户的改变会被立即反映到 props.value ,这是一个真理。

专注于为中小企业提供成都做网站、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业天全免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
Edit on GitHub
disabled 布尔型
如果值为真,那么用户将不能切换开关。默认值为假。
onTintColor 字符串型
当开关打开时候的背景颜色。
onValueChange 函数
当用户切换开关时,调用回调函数。
thumbTintColor 字符串型
开关按钮的背景颜色。
tintColor 字符串型
当开关关闭后的背景颜色。
value 布尔型
开关的值,如果为真,开关会打开。默认值为假。
Edit on GitHub
'use strict';var React = require('react-native');var {
  SwitchIOS,
  Text,
  View
} = React;var BasicSwitchExample = React.createClass({
  getInitialState() {    return {
      trueSwitchIsOn: true,
      falseSwitchIsOn: false,
    };
  },
  render() {    return (
      
         this.setState({falseSwitchIsOn: value})}
          style={{marginBottom: 10}}          value={this.state.falseSwitchIsOn} />
         this.setState({trueSwitchIsOn: value})}          value={this.state.trueSwitchIsOn} />
         
    );
  }
});var DisabledSwitchExample = React.createClass({
  render() {    return (
      
         
    );
  },
});var ColorSwitchExample = React.createClass({
  getInitialState() {    return {
      colorTrueSwitchIsOn: true,
      colorFalseSwitchIsOn: false,
    };
  },
  render() {    return (
      
         this.setState({colorFalseSwitchIsOn: value})}
          onTintColor="#00ff00"
          style={{marginBottom: 10}}
          thumbTintColor="#0000ff"
          tintColor="#ff0000"
          value={this.state.colorFalseSwitchIsOn} />
         this.setState({colorTrueSwitchIsOn: value})}
          onTintColor="#00ff00"
          thumbTintColor="#0000ff"
          tintColor="#ff0000"
          value={this.state.colorTrueSwitchIsOn} />
         
    );
  },
});var EventSwitchExample = React.createClass({
  getInitialState() {    return {
      eventSwitchIsOn: false,
      eventSwitchRegressionIsOn: true,
    };
  },
  render() {    return (
      
        
           this.setState({eventSwitchIsOn: value})}
            style={{marginBottom: 10}}            value={this.state.eventSwitchIsOn} />
           this.setState({eventSwitchIsOn: value})}
            style={{marginBottom: 10}}            value={this.state.eventSwitchIsOn} />
            {this.state.eventSwitchIsOn ? "On" : "Off"} 
           
        
           this.setState({eventSwitchRegressionIsOn: value})}
            style={{marginBottom: 10}}            value={this.state.eventSwitchRegressionIsOn} />
           this.setState({eventSwitchRegressionIsOn: value})}
            style={{marginBottom: 10}}            value={this.state.eventSwitchRegressionIsOn} />
          {this.state.eventSwitchRegressionIsOn ? "On" : "Off"} 
           
       
    );
  }
});
exports.title = '';
exports.displayName = 'SwitchExample';
exports.description = 'Native boolean input';
exports.examples = [
  {
    title: 'Switches can be set to true or false',
    render(): ReactElement { return