Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.82 KB

README.md

File metadata and controls

31 lines (22 loc) · 1.82 KB

DHLayout

简化iOS的布局工作


为什么要写

将UIView的布局工作分离出来,由专门的布局管理器(LayoutManager)来完成布局工作。 好处: 1.UIView不用处理布局相关的事情 2.容易新增布局形式。

  • 1.通过(UIView+Layout)给UIView添加5个布局属性,这样所有UIView都可以参与布局。
  • 2.DHLayoutView是具有布局子视图能力的View。它重写了layoutSubviews方法来实现自己的布局。(代码中提供了它的两个子类DHHorizontalLayoutView和DHVerticalLayoutView,分别用于水平布局和垂直布局)
  • 3.DHLayoutManager用于处理实际布局工作。DHLayoutView的布局工作实际上都会交由内部的DHLayoutManager来完成。(代码中为DHHorizontalLayoutView提供了DHHoritalLayoutManager,为DHVerticalLayoutView提供了DHVerticalLayoutManager)

Class hierarchy

+ DHLayoutView                          
    + DHHorizontalLayoutView            
    + DHVerticalLayoutView

+ DHLayoutManager
    + DHHorizontalLayoutManager
    + DHVerticalLayoutManager

Usage:

  • It was designed to be work with Xib (of course you can use it in Code) , you can set all the property in User Defined Runtime Attributes 此处输入图片的描述
  • you can learn more in the Demo.