zhuxietong / Eelay

极大简化 NSLayoutConstraint 布局方式

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eelay

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Eelay is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Eelay"

Author

zhuxietong, zhuxietong@me.com

License

Eelay is available under the MIT license. See the LICENSE file for more info.

Demo代码分析

demo

26行 对view视图对象的子视图进行布局

28行 将back添加到view中并添加以下布局束

  • 设置back topview top距离为20
  • 设置back leftview left距离为20
  • 设置back bottomview bottom距离为-20
  • 设置back rightview right距离为-20

29行 将head添加到view中并添加以下布局束

  • 设置head width 为 100
  • 设置head height 为 100
  • 设置head topview top 距离为80
  • 设置head centerXview centerX距离为0

30行 将name添加到view中并添加以下布局束

  • 设置name width 小于等于 200
  • 设置name height 为 30
  • 设置name centerXview centerX 距离为-20
  • 设置name tophead bottom 距离为30

31行 将age添加到view中并添加以下布局束

  • 设置age leftname right 距离为10
  • 设置age centerXname centerY对齐

32行 将content添加到view中并添加以下布局束

  • 设置content height 大于等于200,该布局束的优先级为1000
  • 设置content left 相对于view left 距离为30
  • 设置content bottom 相对于view bottom 距离为-30 ,该布局束的优先级为500
  • 设置content right 相对于view right 距离为-30
  • 设置content topname bottom 距离为40

要点分析

将一个视图(label对象)的布局信息放在一个**[Any]**对象中,

1,[Any] 的第一个对象必须是将要布局的视图对象,

[label,]

2,[Any] 中添加 Double或Int或Float值 可设置宽度,

[label,200],

该值处理时转换成[String:Double]类型,类型中包含优先级, 值,大于小于信息;(注:其它的布局约束中,设置的值,中间处理过程也是转换成[String:Double]类型)

3,[Any] 中添加 String 值可设置宽度,

[label,200,"50"],

该值处理时转换成[String:String]类型,类型中包含优先级, 值,大于小于信息

4,[Any]中添加[Any] 对象可简易连续添加多个布局束,

[label,200,"50",[ee.T.L]],

[ee.T.L]中包含top, left 的对齐方式,此时表示lable 与lable父视图的top,left对齐;

[ee.T.L,[20,30]]表示top,left 对齐的偏移量 分别是20,30;

[anther_view,ee.T.L,[20,30]],当第一个对象为视图类型的时候,label 的设置布局束是相对于该视图进行设置,否则的话就是想对于父视图进行设置的

[anther_view,ee.B,ee.T,20],label 的顶部与 anther_view的地步对其

easy map 对应信息NSLayoutAttribute.
ee.T —>  NSLayoutAttribute.top,
ee.L —>  NSLayoutAttribute.left

About

极大简化 NSLayoutConstraint 布局方式

License:MIT License


Languages

Language:Makefile 53.0%Language:Swift 43.1%Language:C 3.2%Language:Ruby 0.7%