You can see this in action in my free water tracking application "Hydrate Yourself". If this helped you please consider downloading it and leaving a review.

One of the great things about iPhone development are that there are lots of user interface pieces that are easy to put together and customize. Unfortunately there are also a lot of pieces which don't have all the basic customizations that may people want. The UISwitch is one of those.

Here is the standard UISwitch:

Its size, colors, and ON / OFF text are not changeable. Fortunately there are several great re-implementations (and a few hacks that use restricted API calls) to modify all this. One that I am using is the RCSwitch class available here.

I made two small changes to this code, first I renamed his RCSwitchOnOff class to RCSwitchYesNo and changed the labels to YES / NO. Second I added an init method to the RCSwitch.m base class which called the usual init function but provided the default frame size. This works fine since I am positioning the x and y coordinates using the "center" property:

The final result looks and behaves just like the original UISwitch, but is actually completely rewritten using the UIControl class. My switches now look like this:

Twitter

Twitter Updates

About Me

Will Winder is a software developer. In his four years of study at UNH he took variety of advanced Computer Science courses including Object Oriented Design, Computer Networks, Artificial Intelligence and Compiler Design. He has been working professionally using C, C++ and Java since graduating in 2006. In his free time he continues to expand his skills by involving himself in many projects, some of which can be seen on this blog.