GGSwitch 0.0.1

GGSwitch 0.0.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最近发布2015 年 5 月

otherplayer 维护。



GGSwitch 0.0.1

  • Otherplayer

使用 Switch 的简便方式

image

用法

导入

#import "GGSwitch.h" 

使用它!

@property (nonatomic, strong) UIColor *onTintColor;

@property (nonatomic, strong) UIColor *tintColor;

@property (nonatomic, strong) UIColor *thumbTintColor;

@property (nonatomic, strong) NSString *onText;

@property (nonatomic, strong) NSString *offText;

@property (nonatomic, unsafe_unretained) CGSize switchSize;// 设置大小, 建议宽高比2:1左右


@property (nonatomic, strong, setter=actionBlock:) void(^tapBlock)(BOOL on);
@property(nonatomic,getter=isOn) BOOL on;



- (instancetype)initWithFrame:(CGRect)frame;    // This class enforces a size appropriate for the control. The frame size is ignored.

- (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action

self.mySwitch = [[GGSwitch alloc] initWithFrame:CGRectMake(10, 100, 400, 400)];//与此大小无关
[self.mySwitch setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:self.mySwitch];

/*可选Start*/
[self.mySwitch setTintColor:[UIColor redColor]];
[self.mySwitch setThumbTintColor:[UIColor whiteColor]];
[self.mySwitch setOnTintColor:[UIColor orangeColor]];
[self.mySwitch setOnText:@"lbs"];
[self.mySwitch setOffText:@"kg"];
[self.mySwitch setSwitchSize:CGSizeMake(100, 50)];//可设置大小
/*End*/

[self.mySwitch setOn:YES animated:YES];

[self.mySwitch actionBlock:^(BOOL on) {
      NSLog(@"============%d",on);
}];

许可证

这些规范和 CocoaPods 在 MIT 许可证 下可用。