Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of Switch while turning OFF react-native

I am using react native switch component and I want to change the color of switch when I turn it OFF.

I can add onTintColor property to change the color when it is turned on.

Is there any way to change the color while turning it OFF?

like image 731
Ankush Rishi Avatar asked Aug 26 '16 06:08

Ankush Rishi


People also ask

How do I change the color on my switch?

From the HOME Menu select "System Settings" > "System" > "Change Display Colours". Select from one of the following options: Default. Invert Colours.

How do I disable switch in react native?

Switch can be disabled by setting the disabled property to true.


1 Answers

onTintColor has been deprecated try the following.

  <Switch 
      trackColor={{true: 'red', false: 'grey'}}
      onValueChange={this.toggleSwitch}
      value={true}/>

this works

like image 121
Shreyash Khole Avatar answered Oct 30 '22 11:10

Shreyash Khole