Skip to content

yangentao/YetLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YetLayout

iOS auto layout by swift


CI Status Version License Platform

let lb = UILabel(frame:CGRect.zero)
self.view.addSubView(lb)

基本用法,属性开头

lb.layout.width.eq(300).active()
lb.layout.width.eq(300).priority(800).ident("mylabel").active()
lb.layout.width.eq(imageView).width.multi(2).offset(8).priority(800).ident("mylabel2").active()

属性相同时, 后面的属性可以省略
lb.layout.width.eq(imageView).active()

lb.layout.left.eq(imageView).right.active()
lb.layout.left.eqParent.active()

组合用法, 函数开头

lb.layout.centerParent().width(200).height(200)
lb.layout.fillX().topParent(16).height(200)
lb.layout.toRightOf(imageView).width(200).topParent(30).height(150)

删除和更新, 更新只能更新constant属性

lb.layout.removeAll()
lb.layout.remove(ident: "mylabel")

lb.layout.width.eq(200).update()
lb.layout.width.eq(200).remove()

Example

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

Requirements

Installation

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

pod 'YetLayout'

Author

yangentao, entaoyang@163.com

License

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