views:

941

answers:

2

I am using UISwitch to make a switch element in my app. It has default color set to blue, but I want to change its color to brown (didn't get a clue via Google except some nasty rumors).

How can I choose a different color for the UISwitch element?

A: 

You will find an answer by using an undocumented feature here. As noted your app might get rejected because of changing the color.

It kind of starts with this:

UISwitch *aSwitch = [[UISwitch alloc] initWithFrame:someRectangle];
[aSwitch setAlternateColors:YES];
//Do something with aSwitch
[aSwitch release];
dlamblin
+1  A: 

Take a look at the custom UISwitch control that I built to allow me to change the background color of the control. You could use the same method to change the text, the font, or the text color very easily.

http://www.homick.com/posts/custom-uiswitch-control

The code is available on Github and includes a PSD that is used to build three different png files that the control uses. You can modify the contents of the psd to recreate the png files in whatever format you like. Swap those into the control and away you go.

This gives a lot more options than just orange and blue.

Duane Homick