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

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

关于第三方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

 

转载地址:http://ccvyo.baihongyu.com/

你可能感兴趣的文章
HTML5:理解head
查看>>
oracle
查看>>
java SpringUtil获取bean
查看>>
Centos6.4最小化安装系统初始化脚本
查看>>
PaaS变厚了
查看>>
赛门铁克开启“容灾即服务”时代
查看>>
复杂度归纳--小结
查看>>
基础篇9-python基本数据结构-列表
查看>>
PHP学习笔记 第八讲 Mysql.简介和创建新的数据库
查看>>
【git】git入门之把自己的项目上传到github
查看>>
js获取鼠标位置
查看>>
2016.8.11 DataTable合并及排除重复方法
查看>>
php 魔术方法 说明
查看>>
Mysql
查看>>
POJ-1860-Currency Exchange
查看>>
跨越企业的“中等收入陷阱”
查看>>
Android 开发者必知的开发资源
查看>>
jackson 常见问题
查看>>
软件工程技术基础-(软件复用技术)
查看>>
给django视图类添加装饰器
查看>>