ERScrollSwitch 0.1

ERScrollSwitch 0.1

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2016

Maintained by Unclaimed.

  • By
  • Alex Nauda

A custom iOS6-style switch similar to UISwitch

Example use:

ERScrollSwtich *switch = [[ERScrollSwitch alloc] initWithFrame:CGRectMake(myX, myY, 79, 28)
                                                         image:[UIImage imageNamed:@"switch-example.png"]

If you would like to be informed when the switch is toggled, set a delegate...


and implement the ERScrollSwitchDelegate protocol.

in WhateverViewController.h:

@interface WhateverViewController : UIViewController <ERScrollSwitchDelegate>

in WhateverViewController.m:

- (void)didToggle:(id)sender {
    // respond to toggle

This switch is based on a UIScrollView. You provide a single custom image including both backgrounds separated by a thumb circle (see switch-example.png and [email protected]) and provide an offset for the location of the thumb. The frame size and offset in the code snippet above correspond to the size and thumb position in the included example images.