UI basic principles

1 Responsibilities

1.1 UIViewController duties

UIView, event manager, responsible for creating dependency.

1.2 UIView duties

  1. It is a sub-view event, CALayer managers.

  2. Process layout.

2 layout

In most cases, it is AutoLayout 自上而下layout, the tree view, the parent node of setting constraints subviews.

So long as we know the roots of the frame can draw a tree view of the whole grain.

In some cases, the lower layout will affect the upper, such as automatic tableView estimates, the new circle of friends reply.

At this time, the tree view child nodes need to tell their parent node to re-calculate their own constraints, and refresh the layout.

3 code organization

3.1 For view

  1. initWithFrame in

    Assembly subview

  2. setModel in

    Configuration data source, needLayout

  3. layoutSubview中

    Process layout

3.2 For viewController

  1. init, only need to pass parameters when we come to need

    Do not appear self.view, only common property assignment (such as model, details page url, etc.)

  2. In viewDidLoad

    Assembled subview

  3. viewWilAppear in

    Processing of data related to the processing system-level tasks (such as statusbar, network monitoring, etc.)

  4. viewDidLayoutSubviews中

    Process layout

  5. subview initialization in the getter

  6. Slimming

    ViewModel、RAC、category

4 common class hierarchy

5 Common practice

The loadingView other common unified operation, wrote a UIViewController's classification.

Reproduced in: https: //juejin.im/post/5d077fa0e51d45105d63a50a

Guess you like

Origin blog.csdn.net/weixin_33766805/article/details/93180868