CMSwitchView 0.1.3

CMSwitchView 0.1.3

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2016 年 10 月

Mycose 维护。



  • 作者:
  • Mycose

CMSwichView

自定义开关视图

CMSwitchView 属性

/// 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 代理:CMSSwitchViewDelegate

当点击开关视图或使用滑动手势移动到中部点之后时调用,并同时发送新的值给你

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

CMSSwitchView 使用示例

    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

安装

CMSwitchView 可通过 CocoaPods 使用。要安装它,只需将以下行添加到 Podfile 中

pod "CMSwitchView"

作者:

Mycose, [email protected]

许可证:

CMSwitchView 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。

待办事项

  • 为点提供图像支持