Latest 0.1.3
Homepage https://github.com/Mycose/CMSwitchView
License MIT
Platforms ios 7.0, requires ARC
Authors

CMSwichView

Customizable switch view

CMSwitchView Properties:

/// If you want to have rounded dots and switch view or not, YES by default
@property (nonatomic, assign) BOOL rounded;
/// Width of the border, 1 by default
@property (nonatomic, assign) CGFloat borderWidth;
/// color of the border, white by default
@property (nonatomic, assign) UIColor* borderColor;
/// color of the background of the switch view, clearColor by default
@property (nonatomic, strong) UIColor* color;
/// color of the background of the switch view when switched, clearColor by default
@property (nonatomic, strong) UIColor* tintColor;
/// width and height of the dot, frameHeight-2 by default
@property (nonatomic, assign) CGFloat dotWeight;
/// color of the dot, white by default
@property (nonatomic, strong) UIColor* dotColor;
/// duration of the animation, 0.6 by default
@property (nonatomic, assign) NSTimerInterval animDuration;
/// delegate to be set
@property (nonatomic, weak) id<CMSwitchViewDelegate> delegate;

CMSSwitchView Delegation : CMSSwitchViewDelegate

Called when the switch view is clicked or when you move the dot after the middle with the pan gesture, sending you the new value

- (void)switchValueChanged:(id)sender andNewValue:(BOOL)value;

CMSSwitchView Usage Example:

    self.firstSwitch = [[CMSwitchView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-150, 100, 300, 50)];
    self.firstSwitch.dotColor = [UIColor blueColor];
    self.firstSwitch.color = [UIColor whiteColor];
    self.firstSwitch.tintColor = [UIColor clearColor];
    [self.view addSubview:self.firstSwitch];

    self.secondSwitch = [[CMSwitchView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-100, self.firstSwitch.frame.size.height+self.firstSwitch.frame.origin.y+100, 200, 60)];
    self.secondSwitch.dotColor = [UIColor whiteColor];
    self.secondSwitch.color = [UIColor clearColor];
    self.secondSwitch.tintColor = [UIColor clearColor];
    self.secondSwitch.dotWeight = 20.f;
    [self.view addSubview:self.secondSwitch];

    self.thirdSwitch = [[CMSwitchView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-50, self.secondSwitch.frame.size.height+self.secondSwitch.frame.origin.y+100, 100, 30)];
    self.thirdSwitch.animDuration = 2.f;
    self.thirdSwitch.isRounded = NO;
    [self.view addSubview:self.thirdSwitch];

Gif

Installation

CMSwitchView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "CMSwitchView"

Author

Mycose, [email protected]

License

CMSwitchView is available under the MIT license. See the LICENSE file for more info.

TODO

  • Support for images for the dots

Latest podspec

{
    "name": "CMSwitchView",
    "version": "0.1.3",
    "summary": "CMSwitchView is a cool customizable switch view and with a pan gesture on it.",
    "description": "You can customize for now the background color when selected or not. The border width and color.n                        The width/height of the dot. If you want rounded or not.",
    "homepage": "https://github.com/Mycose/CMSwitchView",
    "license": "MIT",
    "authors": {
        "Mycose": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Mycose/CMSwitchView.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "CMSwitchView/Pod/Classes/**/*"
}

Pin It on Pinterest

Share This