博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于第三方IOS的checkBox框架的使用
阅读量:6041 次
发布时间:2019-06-20

本文共 6230 字,大约阅读时间需要 20 分钟。

hot3.png

关于第三方IOS的checkBox框架的使用

这个框架是从github上下载获取的:M13Checkbox。只是github的源码项目工程比较久远,所以我把代码部分拷贝到XCode 7.1.0新建的项目里。

下面是展示效果

 

 

客户端源码使用参考:

1 #import "ViewController.h"  2 #import "M13Checkbox.h"  3   4 @interface ViewController ()  5   6 @end  7   8 @implementation ViewController  9  10 - (void)viewDidLoad 11 { 12     [super viewDidLoad]; 13     self.view.backgroundColor = [UIColor whiteColor]; 14     // Do any additional setup after loading the view, typically from a nib. 15      16     //Create just a box with the default size 17     M13Checkbox *allDefaults = [[M13Checkbox alloc] init]; 18     allDefaults.frame = CGRectMake(25, 25, allDefaults.frame.size.width, allDefaults.frame.size.height); 19     [allDefaults addTarget:self action:@selector(checkChangedValue:) forControlEvents:UIControlEventValueChanged]; 20     [self.view addSubview:allDefaults]; 21      22     //Basic Title 23     M13Checkbox *basicTitle = [[M13Checkbox alloc] initWithTitle:@"Basic Title"]; 24     basicTitle.frame = CGRectMake(25, allDefaults.frame.origin.y + allDefaults.frame.size.height + 8, basicTitle.frame.size.width, basicTitle.frame.size.height); 25     [self.view addSubview:basicTitle]; 26      27     //Title With custom height 28     M13Checkbox *titleWithHeight = [[M13Checkbox alloc] initWithFrame:CGRectMake(25, basicTitle.frame.origin.y + basicTitle.frame.size.height + 8, 100, 30) title:@"Custom Height" checkHeight:30.0]; 29     [self.view addSubview:titleWithHeight]; 30      31     //Left Alignment 32     M13Checkbox *leftAlignment = [[M13Checkbox alloc] initWithTitle:@"M13CheckboxAlignmentLeft"]; 33     [leftAlignment setCheckAlignment:M13CheckboxAlignmentLeft]; 34     leftAlignment.frame = CGRectMake(25, titleWithHeight.frame.origin.y +titleWithHeight.frame.size.height + 8, leftAlignment.frame.size.width, leftAlignment.frame.size.height); 35      36     [self.view addSubview:leftAlignment]; 37      38     //Mixed 39     M13Checkbox *mixed = [[M13Checkbox alloc] initWithTitle:@"M13CheckboxStateMixed"]; 40     [mixed setCheckState:M13CheckboxStateMixed]; 41     mixed.frame = CGRectMake(25, leftAlignment.frame.origin.y + leftAlignment.frame.size.height + 8, mixed.frame.size.width, mixed.frame.size.height); 42     [self.view addSubview:mixed]; 43      44     //OSX-Style 45     M13Checkbox *osx = [[M13Checkbox alloc] initWithTitle:@"OSX Style"]; 46     osx.flat = NO; 47     osx.frame = CGRectMake(25, mixed.frame.origin.y + mixed.frame.size.height + 8, osx.frame.size.width, osx.frame.size.height); 48     osx.strokeColor = [UIColor colorWithRed: 0.167 green: 0.198 blue: 0.429 alpha: 1]; 49     osx.checkColor = [UIColor colorWithRed:0.0 green:0.129 blue:0.252 alpha:1.0]; 50     osx.tintColor = [UIColor colorWithRed: 0.616 green: 0.82 blue: 0.982 alpha: 1]; 51     osx.uncheckedColor = [UIColor colorWithRed:0.925 green:0.925 blue:0.925 alpha:1.0]; 52     [self.view addSubview:osx]; 53      54     //Custom Stroke 55     M13Checkbox *stroke = [[M13Checkbox alloc] initWithFrame:CGRectMake(25, osx.frame.origin.y + osx.frame.size.height + 8, 100, 30) title:@"Custom Stroke" checkHeight:30.0]; 56     stroke.strokeColor = [UIColor redColor]; 57     stroke.strokeWidth = 3.0; 58     [stroke autoFitWidthToText]; 59     [self.view addSubview:stroke]; 60      61     //Custom Check Color 62     M13Checkbox *check = [[M13Checkbox alloc] initWithTitle:@"Custom Check Color"]; 63     check.checkColor = [UIColor blueColor]; 64     check.frame = CGRectMake(25, stroke.frame.origin.y + stroke.frame.size.height + 8, check.frame.size.width, check.frame.size.height); 65     [self.view addSubview:check]; 66      67     //Custom tint color 68     M13Checkbox *tint = [[M13Checkbox alloc] initWithTitle:@"Custom Tint Color"]; 69     tint.tintColor = [UIColor colorWithRed: 0.608 green: 0.967 blue: 0.646 alpha: 1]; 70     tint.frame = CGRectMake(25, check.frame.origin.y + check.frame.size.height + 8, tint.frame.size.width, tint.frame.size.height); 71     [self.view addSubview:tint]; 72      73     //Custom Unchecked Color 74     M13Checkbox *unchecked = [[M13Checkbox alloc] initWithTitle:@"Custom Unchecked Color"]; 75     unchecked.uncheckedColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1.0]; 76     unchecked.frame = CGRectMake(25, tint.frame.origin.y + tint.frame.size.height + 8, unchecked.frame.size.width, unchecked.frame.size.height); 77     [self.view addSubview:unchecked]; 78      79     //Custom Radius 80     M13Checkbox *radius = [[M13Checkbox alloc] initWithTitle:@"Custom Radius"]; 81     radius.radius = 5.0; 82     radius.frame = CGRectMake(25, unchecked.frame.origin.y + unchecked.frame.size.height + 8, radius.frame.size.width, radius.frame.size.height); 83     [self.view addSubview:radius]; 84      85     //Disabled 86     M13Checkbox *disabled = [[M13Checkbox alloc] initWithTitle:@"Disabled"]; 87     disabled.enabled = NO; 88     disabled.frame = CGRectMake(25, radius.frame.origin.y + radius.frame.size.height + 8, disabled.frame.size.width, disabled.frame.size.height); 89     [self.view addSubview:disabled]; 90      91     //Disabled Checked 92     M13Checkbox *disabledChecked = [[M13Checkbox alloc] initWithTitle:@"Disabled Checked"]; 93     disabledChecked.enabled = NO; 94     [disabledChecked setCheckState:M13CheckboxStateChecked]; 95     disabledChecked.frame = CGRectMake(25, disabled.frame.origin.y + disabled.frame.size.height + 8, disabledChecked.frame.size.width, disabledChecked.frame.size.height); 96     [self.view addSubview:disabledChecked]; 97      98     //Custom Frame + Multiline text 99     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];100     customFrame.backgroundColor = [UIColor lightGrayColor];101     customFrame.titleLabel.numberOfLines = 0;102     customFrame.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;103     [self.view addSubview:customFrame];104 }105 106 - (void)checkChangedValue:(id)sender107 {108     NSLog(@"Changed Value");109 }110 111 @end

 

 

 

XCode7.1.0备份更新的源代码百度云备份链接:  密码: qvmx

 

转载于:https://my.oschina.net/u/2363463/blog/635612

你可能感兴趣的文章
关于云栖,有点无语的几个地方,管理能不能管?
查看>>
Windows线程的同步与互斥
查看>>
C#进阶系列——MEF实现设计上的“松耦合”(四):构造函数注入
查看>>
AngularJs ng-change事件/指令(转)
查看>>
linux系统下安装两个或多个tomcat
查看>>
ProtoBuffer 简单例子
查看>>
iOS多线程开发系列之(一)NSThread
查看>>
微信小程序初体验(上)- 腾讯ISUX社交用户体验设计成员出品
查看>>
SAP WM Physical Inventory Method ST & PZ
查看>>
一次快速的数据迁移感悟
查看>>
《ELK Stack权威指南(第2版)》一3.6 Java日志
查看>>
C++流的streambuf详解及TCP流的实现
查看>>
《量化金融R语言初级教程》一2.5 协方差矩阵中的噪声
查看>>
beetl 和 shrio 结合
查看>>
相对/绝对路径,cd命令,mkdir/rmdir命令,rm命令
查看>>
tomcat中web.xml各配置项的意义
查看>>
Nodejs学习笔记(二):《node.js开发指南》代码中需要注意的几点
查看>>
Ztree异步加载自动展开节点
查看>>
反射操作公共成员变量
查看>>
Android热修复升级探索——代码修复冷启动方案
查看>>