文章来源:淘论文网   发布者: 毕业设计   浏览量: 40



还可以点击去查询以下关键词:
[链式]    [毕业]    [编程]    [iOS 链式毕业编程]   

项目介绍:

一个iOS链式开发的小工具。

github:https://github.com/tengshuq/ChainFunction

常用的控件实现链式编程的一个小框架。。 一般我们创建的代码的方式

UILabel *test1 = [[UILabel alloc] init]; test1.frame = CGRectMake(20, 50, 100, 30); test1.font = [UIFont systemFontOfSize:13]; test1.text = @'古今多少事'; test1.textColor = [UIColor whiteColor]; test1.backgroundColor = [UIColor lightGrayColor]; test1.textAlignment = NSTextAlignmentCenter; test1.layer.cornerRadius = 3.f; test1.layer.borderColor = [UIColor greenColor].CGColor; test1.layer.borderWidth = 1.f; [self.view addSubview:test1];

现在,你可以这样创建

UILabel *label = [[UILabel alloc] init]; label.labelChain // 取到labelChain .font([UIFont systemFontOfSize:13]) .text(@'链式作死') .textColor([UIColor greenColor]) .viewMaker() // 调用到UIView的链 .frame(CGRectMake(20, 100, 100, 40)) .backgroundColor([UIColor whiteColor]) .addToSuperView(self.view) .labelMaker() // 可以再回调到label链 .textAlignment(NSTextAlignmentCenter) .layerMaker() // 调到layer链 .cornerRadius(5) .borderColor([UIColor redColor].CGColor) .borderWidth(1.f);

这里,开题报告,UILabel的链不能直接调用UIView链上的属性或方法,需要先调用到UIView的链上面,开题报告,也就是.viewMaker(),同样的,其他子类也要调用父类的时候属性或方法的时候也需要这么做,同时,父类也可以再调用到子类的链上面,比如.labelMaker()

要注意的一点,调用到CALayer的链.layerMaker()之后,不能再回调回来,所以,最好在最后调用Layer链。因为这个属性的特殊性,每个子类都能直接调用.layerMaker()

目前支持的类有UIView,UILabel,UIScrollView,UITableView,UICollectionView,UICollectionViewFlowLayout,UIControl UIButton,UITextView,UITextField,UIImageView,还有CALayer

作为UITextField和UITextView最常用且比较容易忽略的UITextInputTraits协议中的方法,这里分别复制到了UITextField和UITextView 两个类中,以便使用。。。我在想UIControl中的方法要不要也复制到UIButton和UITextField中去。。。


这里还有:


还可以点击去查询:
[链式]    [毕业]    [编程]    [iOS 链式毕业编程]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/3119.docx
  • 上一篇:JPImageresizerView 0.3.1 --- 仿定制微信裁剪图片的一个裁剪小工具
  • 下一篇:UITableView无数据时的提示UITableViewPlaceholder