ChainControl 1.0.0

ChainControl 1.0.0

XueYangLee 维护。



  • 作者:
  • XueYangLee

ChainControl

CI Status Version License Platform

Swift基础控件 UILabel、UIButton、UITextField、UITextView、UIImageView、UIView 链式写法,简化代码

利用链式编程方法简化基础控件的写法,需要的属性可以向后拼接

安装使用

  • 导入 pods
pod 'ChainControl'
  • 手动导入,直接拖拽 ChainControl 文件夹到您的项目中

代码对比示例

  • 原生示例
let btn = UIButton(frame: CGRect(x: 10, y: 200, width: 50, height: 50))
btn.setTitle("button", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 16)
btn.backgroundColor = .blue
btn.layer.shadowColor = UIColor.gray.cgColor
btn.layer.shadowOpacity = 1
btn.layer.shadowOffset = CGSize(width: 1, height: 1)
btn.layer.shadowRadius = 2
self.view.addSubview(btn)
  • ChainControl 示例
let btnExample = UIButton(frame: CGRect(x: 10, y: 100, width: 50, height: 50)).ctrl_title("button").ctrl_titleColor(.white).ctrl_font(.systemFont(ofSize: 16)).ctrl_backgroundColor(.blue).ctrl_shadow(color: .gray)
self.view.addSubview(btnExample)