mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-12 22:33:59 +08:00
Update automatic-layout-basics.md
This commit is contained in:
@@ -28,31 +28,7 @@ Every ASLayoutSpec must act on at least one child. The ASLayoutSpec has the resp
|
||||
|
||||
You don’t need to be aware of **`ASLayout`** except to know that it represents a computed immutable layout tree and is returned by objects conforming to the `<ASLayoutable>` protocol.
|
||||
|
||||
##Layout Containers
|
||||
|
||||
AsyncDisplayKit includes a library of components that can be composed to declaratively specify a layout. The following LayoutSpecs allow you to have multiple children:
|
||||
|
||||
* **ASStackLayoutSpec** is based on a simplified version of CSS flexbox. It allows you to stack components vertically or horizontally and specify how they should be flexed and aligned to fit in the available space.
|
||||
* **ASStaticLayoutSpec** allows positioning children at fixed offsets.
|
||||
|
||||
The following layoutSpecs allow you to layout a single children:
|
||||
|
||||
* **ASLayoutSpec** can be used as a spacer if it contains no children
|
||||
* **ASInsetLayoutSpec** applies an inset margin around a component.
|
||||
* **ASBackgroundLayoutSpec** lays out a component, stretching another component behind it as a backdrop.
|
||||
* **ASOverlayLayoutSpec** lays out a component, stretching another component on top of it as an overlay.
|
||||
* **ASCenterLayoutSpec** centers a component in the available space.
|
||||
* **ASRatioLayoutSpec** lays out a component at a fixed aspect ratio. Great for images, gifs and videos.
|
||||
* **ASRelativeLayoutSpec** lays out a component and positions it within the layout bounds according to vertical and horizontal positional specifiers. Similar to the “9-part” image areas, a child can be positioned at any of the 4 corners, or the middle of any of the 4 edges, as well as the center.
|
||||
|
||||
##Implementing layoutSpecThatFits:
|
||||
|
||||
##Strategy
|
||||
|
||||
##Layout for UIKit Components:
|
||||
- for UIViews that are added directly, you will still need to manually lay it out in `didLoad:`
|
||||
- for UIViews that are added ASDisplay initWithViewBlock, you can then include it in `layoutSpecThatFits:`
|
||||
|
||||
##Debugging with ASCII Art
|
||||
|
||||
##Legacy Layout Methods
|
||||
|
||||
Reference in New Issue
Block a user