关于第三方IOS的checkBox框架的使用
2015-12-03 23:16
821 查看
关于第三方IOS的checkBox框架的使用
这个框架是从github上下载获取的:M13Checkbox。 只是github的源码项目工程比较久远,所以我把代码部分拷贝到XCode 7.1.0新建的项目里。
下面是展示效果
客户端源码使用参考:
#import "ViewController.h" #import "M13Checkbox.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; // Do any additional setup after loading the view, typically from a nib. //Create just a box with the default size M13Checkbox *allDefaults = [[M13Checkbox alloc] init]; allDefaults.frame = CGRectMake(25, 25, allDefaults.frame.size.width, allDefaults.frame.size.height); [allDefaults addTarget:self action:@selector(checkChangedValue:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:allDefaults]; //Basic Title M13Checkbox *basicTitle = [[M13Checkbox alloc] initWithTitle:@"Basic Title"]; basicTitle.frame = CGRectMake(25, allDefaults.frame.origin.y + allDefaults.frame.size.height + 8, basicTitle.frame.size.width, basicTitle.frame.size.height); [self.view addSubview:basicTitle]; //Title With custom height M13Checkbox *titleWithHeight = [[M13Checkbox alloc] initWithFrame:CGRectMake(25, basicTitle.frame.origin.y + basicTitle.frame.size.height + 8, 100, 30) title:@"Custom Height" checkHeight:30.0]; [self.view addSubview:titleWithHeight]; //Left Alignment M13Checkbox *leftAlignment = [[M13Checkbox alloc] initWithTitle:@"M13CheckboxAlignmentLeft"]; [leftAlignment setCheckAlignment:M13CheckboxAlignmentLeft]; leftAlignment.frame = CGRectMake(25, titleWithHeight.frame.origin.y +titleWithHeight.frame.size.height + 8, leftAlignment.frame.size.width, leftAlignment.frame.size.height); [self.view addSubview:leftAlignment]; //Mixed M13Checkbox *mixed = [[M13Checkbox alloc] initWithTitle:@"M13CheckboxStateMixed"]; [mixed setCheckState:M13CheckboxStateMixed]; mixed.frame = CGRectMake(25, leftAlignment.frame.origin.y + leftAlignment.frame.size.height + 8, mixed.frame.size.width, mixed.frame.size.height); [self.view addSubview:mixed]; //OSX-Style M13Checkbox *osx = [[M13Checkbox alloc] initWithTitle:@"OSX Style"]; osx.flat = NO; osx.frame = CGRectMake(25, mixed.frame.origin.y + mixed.frame.size.height + 8, osx.frame.size.width, osx.frame.size.height); osx.strokeColor = [UIColor colorWithRed: 0.167 green: 0.198 blue: 0.429 alpha: 1]; osx.checkColor = [UIColor colorWithRed:0.0 green:0.129 blue:0.252 alpha:1.0]; osx.tintColor = [UIColor colorWithRed: 0.616 green: 0.82 blue: 0.982 alpha: 1]; osx.uncheckedColor = [UIColor colorWithRed:0.925 green:0.925 blue:0.925 alpha:1.0]; [self.view addSubview:osx]; //Custom Stroke M13Checkbox *stroke = [[M13Checkbox alloc] initWithFrame:CGRectMake(25, osx.frame.origin.y + osx.frame.size.height + 8, 100, 30) title:@"Custom Stroke" checkHeight:30.0]; stroke.strokeColor = [UIColor redColor]; stroke.strokeWidth = 3.0; [stroke autoFitWidthToText]; [self.view addSubview:stroke]; //Custom Check Color M13Checkbox *check = [[M13Checkbox alloc] initWithTitle:@"Custom Check Color"]; check.checkColor = [UIColor blueColor]; check.frame = CGRectMake(25, stroke.frame.origin.y + stroke.frame.size.height + 8, check.frame.size.width, check.frame.size.height); [self.view addSubview:check]; //Custom tint color M13Checkbox *tint = [[M13Checkbox alloc] initWithTitle:@"Custom Tint Color"]; tint.tintColor = [UIColor colorWithRed: 0.608 green: 0.967 blue: 0.646 alpha: 1]; tint.frame = CGRectMake(25, check.frame.origin.y + check.frame.size.height + 8, tint.frame.size.width, tint.frame.size.height); [self.view addSubview:tint]; //Custom Unchecked Color M13Checkbox *unchecked = [[M13Checkbox alloc] initWithTitle:@"Custom Unchecked Color"]; unchecked.uncheckedColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1.0]; unchecked.frame = CGRectMake(25, tint.frame.origin.y + tint.frame.size.height + 8, unchecked.frame.size.width, unchecked.frame.size.height); [self.view addSubview:unchecked]; //Custom Radius M13Checkbox *radius = [[M13Checkbox alloc] initWithTitle:@"Custom Radius"]; radius.radius = 5.0; radius.frame = CGRectMake(25, unchecked.frame.origin.y + unchecked.frame.size.height + 8, radius.frame.size.width, radius.frame.size.height); [self.view addSubview:radius]; //Disabled M13Checkbox *disabled = [[M13Checkbox alloc] initWithTitle:@"Disabled"]; disabled.enabled = NO; disabled.frame = CGRectMake(25, radius.frame.origin.y + radius.frame.size.height + 8, disabled.frame.size.width, disabled.frame.size.height); [self.view addSubview:disabled]; //Disabled Checked M13Checkbox *disabledChecked = [[M13Checkbox alloc] initWithTitle:@"Disabled Checked"]; disabledChecked.enabled = NO; [disabledChecked setCheckState:M13CheckboxStateChecked]; disabledChecked.frame = CGRectMake(25, disabled.frame.origin.y + disabled.frame.size.height + 8, disabledChecked.frame.size.width, disabledChecked.frame.size.height); [self.view addSubview:disabledChecked]; //Custom Frame + Multiline text M13Checkbox *customFrame = [[M13Checkbox alloc] initWithFrame:CGRectMake(25, disabledChecked.frame.origin.y + disabledChecked.frame.size.height + 8, 200, 100) title:@"Custom control frame and multiple lines of text." checkHeight:M13CheckboxDefaultHeight]; customFrame.backgroundColor = [UIColor lightGrayColor]; customFrame.titleLabel.numberOfLines = 0; customFrame.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; [self.view addSubview:customFrame]; } - (void)checkChangedValue:(id)sender { NSLog(@"Changed Value"); } @end
XCode7.1.0备份更新的源代码百度云备份链接: http://pan.baidu.com/s/1ntzX3GP 密码: qvmx
相关文章推荐
- ios入门第一课
- 项目适配iOS9遇到的一些问题及解决办法(更新两个小问题)
- IOS 入门之基础控件学习1
- IOS ---设置导航栏
- iOS初体验
- IOS 退出程序APP代码
- 蓝懿ios 技术内容和心得 12.3
- iOS-OC-基础-NSPredicate常用方法
- iOS开发见闻-第9期
- iOS 6.0 Masonry自动布局表头/表尾时崩溃解决方案
- iOS开发 - 百度地图
- XCode安装插件无效的解决办法
- iOS开发之图片拉伸
- iOS 国际化
- [iOS] 使用CIColorCube快速製作濾鏡
- 浅析iOS的@property属性
- IOS程序之间的文件共享
- iOS Get同步与异步
- Local declaration of 'XXX' hides instance variable
- 单例模式两种创建方法详解