Switch is a UIControl subclass that creates a UISwitch like control with provided image.
Objective-C Ruby
Latest commit 9566813 Aug 5, 2014 @taruntyagi697 Deleted Private Pod.
Permalink
Failed to load latest commit information.
Example Added podspec. Aug 2, 2014
Screenshots Updated Screenshots. Jul 15, 2014
Switch Deleted Private Pod. Aug 4, 2014
LICENSE.md Finalized Switch. Jul 15, 2014
README.md Fixed switch expexted artwork in ReadME. Aug 2, 2014
Switch.podspec Added podspec. Aug 2, 2014

README.md

Switch - iOS (Objective-C)

Switch is a UIControl subclass that creates a UISwitch like control with provided image.

Requirements

  • iOS 6.0 or later
  • QuartzCore.framework
  • ARC (either project has ARC ON or Switch is compiled with -fobjc-arc)

Installation

  • Like to go with CocoaPods, add following to your podfile-
pod 'Switch'
  • If you wish to copy the source files directly, that's up to you.

How To Use

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];
  • Switch uses the image and visible width combination to toggle between states.
  • You can provide cornerRadius of your choice to make it appear roundedCorner style or any other.

What's the catch ?

It's the simplest, yet the appearance is all yours!

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 :- SwitchImage

How It Looks

Screenshot1 Screenshot2

Demo App

Demo app includes an example just for reference.