Skip to content

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

License

Notifications You must be signed in to change notification settings

XueYangLee/ChainControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published