示例
import React, { Component } from 'react';
import {Switch,StyleSheet,} from 'react-native';
export class pageComponent extends Component {
constructor(props){
super(props);
this.state={
swicthValue: false
}
}
onChange =(value)=>{
this.setState({
value: value
})
};
render(){
return(
<Switch style={styles.switch}
onTintColor={'#ff00ff'}
tintColor={'#00ffff'}
value={this.state.swicthValue}
onValueChange={(value)=> {
this.setState({
swicthValue: value
})
}}
testID={'one'}
thumbTintColor={'#ffff00'}/>
)
}
}
const styles = StyleSheet.create({
switch: {
marginTop: 100,
},
});