Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the UISwitch default color(blue)

How to change the default color(blue) of a UISwitch?

like image 661
Prasad Avatar asked Dec 22 '11 11:12

Prasad


People also ask

How do I change the color on my UISwitch?

You can use the tintColor property on the switch. Setting tintColor in iOS7 removes "outline" for me (tint white against white background).

How do I change the toggle color in SwiftUI?

There is no way to change the tint color of Toggle from SwiftUI, but we can use UIAppearance API from UIKit to set the tint color for all UISwitch instances across the app. You can paste this line in AppDelegate to configure the color before you create a view.


2 Answers

I think what you are looking for is something like this

UISwitch *testSwitch; //just something I made up [testSwitch setOnTintColor:[UIColor greenColor]]; 
like image 101
NicholasTGD Avatar answered Sep 20 '22 09:09

NicholasTGD


In Xcode 5 and iOS 7 it's now in the attributes inspector:

enter image description here

Changing the On Tint will change the button's color when it's turned on.

enter image description here

I hope that's what you were looking for! Even though you posted that question like three years ago.

like image 22
jeddai Avatar answered Sep 21 '22 09:09

jeddai