Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

outl4nd3r

macrumors member
Original poster
Apr 6, 2008
31
0
Hi,
I have an app that has a fine wood background, I would like the controls to follow the same look and feel. So, I was wonder if there is a way to change the look of the UISwitch? I would like to make the control look like it was made of wood. I've found how to change the text but not the look.

I'm thinking I have to create a subclass of UISwitch, but I can't think of the direction to go after that.

Any help would be much appreciated. Thanks :eek:
 
Hi,
I have an app that has a fine wood background, I would like the controls to follow the same look and feel. So, I was wonder if there is a way to change the look of the UISwitch? I would like to make the control look like it was made of wood. I've found how to change the text but not the look.

I'm thinking I have to create a subclass of UISwitch, but I can't think of the direction to go after that.

Any help would be much appreciated. Thanks :eek:

In your subclass override drawRect:. You may well need to override other methods too if your switch does not draw in exactly the same place as the Apple one. Also not sure about setOn:animated:. You might have to override this too (if you call it) to get the correct animation.
 
There isn't that much to the UISwitch class. You might do just as well to start with an override of UIControl. There's no way to customize UISwitch using the public SDK methods.

You'd need to do some mouse tracking and custom drawing of how you want your switch to look. You can easily add your own setOn property to make your switch similar to UISwitch.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.