新聞中心
使用 SwitchIOS 在 iOS 上呈現(xiàn)出布爾型的輸入。這是一個(gè)控件組件,所以為了更新組件,你必須使用 onValueChange回調(diào)并且更新值value。否則的話用戶的改變會(huì)被立即反映到 props.value ,這是一個(gè)真理。

專注于為中小企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)天全免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000+企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
屬性
Edit on GitHub
disabled 布爾型
如果值為真,那么用戶將不能切換開關(guān)。默認(rèn)值為假。
onTintColor 字符串型
當(dāng)開關(guān)打開時(shí)候的背景顏色。
onValueChange 函數(shù)
當(dāng)用戶切換開關(guān)時(shí),調(diào)用回調(diào)函數(shù)。
thumbTintColor 字符串型
開關(guān)按鈕的背景顏色。
tintColor 字符串型
當(dāng)開關(guān)關(guān)閉后的背景顏色。
value 布爾型
開關(guān)的值,如果為真,開關(guān)會(huì)打開。默認(rèn)值為假。
例子
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 ; }
},
{
title: 'Switches can be disabled',
render(): ReactElement { return ; }
},
{
title: 'Custom colors can be provided',
render(): ReactElement { return ; }
},
{
title: 'Change events can be detected',
render(): ReactElement { return ; }
},
{
title: 'Switches are controlled components',
render(): ReactElement { return ; }
}
]; 網(wǎng)站名稱:創(chuàng)新互聯(lián)React教程:iOS開關(guān)
本文路徑:http://www.dlmjj.cn/article/djgepdi.html


咨詢
建站咨詢
