/RSSwitch

Custom Switch for iOS, based on UIControl class.

Primary LanguageObjective-CMIT LicenseMIT

RSSwitch

Custom Switch for iOS, based on UIControl class.

Primitive and easy customizable switch for iOS.

A preview of this control

RSSwitch *myswitch = [[RSSwitch alloc] initWithFrame:CGRectMake(30, 30, 100, 50)];
[myswitch setOnColor:[UIColor greenColor]];
[myswitch setOffColor:[UIColor whiteColor]];

// you can easily change border radius/color/width by accessing switch view layer 
[myswitch setBorderColor:[UIColor lightGrayColor]];
myswitch.handleView.backgroundColor = [UIColor whiteColor];
myswitch.handleView.layer.borderColor = [UIColor lightGrayColor].CGColor;

// switch notificate you for events UIControlEventTouchUpInside and UIControlEventTouchUpOutnside
[myswitch addTarget:self action:@selector(switchSwitched:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:myswitch];
-(void)switchSwitched:(RSSwitch *)sender {
    NSLog(@"state: %i", sender.isOn);
}

License

RSSwitch is licensed under the terms of the MIT license. Please see the LICENSE file for full details.