TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Tarun Tyagi.
Switch
is a UIControl
subclass that creates a UISwitch like control with provided image.
-fobjc-arc
)pod 'Switch'
Using Switch is quite simple :
UIImage* image = [UIImage imageNamed:@"switch.png"];
Switch* mySwitch = [Switch switchWithImage:image visibleWidth:200];
[mySwitch addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:mySwitch];
You can provide any image, just one complete image containing ON-THUMB-OFF (see image below) both states
(for reference, see SwitchArtwork
in demo app)
and visibleWidth to toggle between states, and that's it.
All that appearance depends on how creative your artwork is. A typical expected Switch image must be of form :-
Demo app includes an example just for reference.