I just created a demo project on github that uses a custom subclass of UIButton, WTToggleButton.
The WTToggleButton class gives a checkbox like button. Click it and it changes state to the selected state. Click it again and it changes back. It uses the UIControl "selected" property to track it's selected/not selected state.
You can download the project from github at this link WTToggleButton project on github
In order to use the new class, do the following:
- Drag the WTToggleButton.h and .m files into your project. Select "Copy files..." and make sure they are added to your project target(s).
- In your view controller's viewDidLoad method, add code to set the selectedImage and notSelectedImage properties of the image.
- Connect actions to the "Value Changed" event for the button. Then, when the user clicks on the checkbox, you'll be notified.
- Use the "selected" status of the button to see if it is in it's selected state.
Note that I provided sample graphics for the selected and not selected states, but those graphics belong to my company. You will need to create your own graphics.
The project uses ARC and storyboards. It does not use autolayout so it should work on iOS 5.0 or later.
It uses the bare minimum of internationalization code: Calling NSLocalizedString() on any string that is displayed through code. It would be a simple matter to localize this app for other languages.
Animated GIF created with Face Dancer
, available for free in the app store.
I'm available for one-on-one help at CodeMentor