ASStackLayoutSpec Class Reference
| Inherits from | ASLayoutSpec : NSObject |
|---|---|
| Declared in | ASStackLayoutSpec.h |
Overview
A simple layout spec that stacks a list of children vertically or horizontally.
- All children are initially laid out with the an infinite available size in the stacking direction.
- In the other direction, this spec’s constraint is passed.
- The children’s sizes are summed in the stacking direction.
- If this sum is less than this spec’s minimum size in stacking direction, children with flexGrow are flexed.
- If it is greater than this spec’s maximum size in the stacking direction, children with flexShrink are flexed.
- If, even after flexing, the sum is still greater than this spec’s maximum size in the stacking direction, justifyContent determines how children are laid out.
For example:
- Suppose stacking direction is Vertical, min-width=100, max-width=300, min-height=200, max-height=500.
- All children are laid out with min-width=100, max-width=300, min-height=0, max-height=INFINITY.
- If the sum of the children's heights is less than 200, children with flexGrow are flexed larger.
- If the sum of the children's heights is greater than 500, children with flexShrink are flexed smaller.
Each child is shrunk by
((sum of heights) - 500)/(number of flexShrink-able children). - If the sum of the children's heights is greater than 500 even after flexShrink-able children are flexed, justifyContent determines how children are laid out.
direction
Specifies the direction children are stacked in. If horizontalAlignment and verticalAlignment were set, they will be resolved again, causing justifyContent and alignItems to be updated accordingly
@property (nonatomic, assign) ASStackLayoutDirection directionDeclared In
ASStackLayoutSpec.h
spacing
The amount of space between each child.
@property (nonatomic, assign) CGFloat spacingDeclared In
ASStackLayoutSpec.h
horizontalAlignment
Specifies how children are aligned horizontally. Depends on the stack direction, setting the alignment causes either justifyContent or alignItems to be updated. The alignment will remain valid after future direction changes. Thus, it is preferred to those properties
@property (nonatomic, assign) ASHorizontalAlignment horizontalAlignmentDeclared In
ASStackLayoutSpec.h
verticalAlignment
Specifies how children are aligned vertically. Depends on the stack direction, setting the alignment causes either justifyContent or alignItems to be updated. The alignment will remain valid after future direction changes. Thus, it is preferred to those properties
@property (nonatomic, assign) ASVerticalAlignment verticalAlignmentDeclared In
ASStackLayoutSpec.h
justifyContent
The amount of space between each child.
@property (nonatomic, assign) ASStackLayoutJustifyContent justifyContentDeclared In
ASStackLayoutSpec.h
alignItems
Orientation of children along cross axis
@property (nonatomic, assign) ASStackLayoutAlignItems alignItemsDeclared In
ASStackLayoutSpec.h
baselineRelativeArrangement
If YES the vertical spacing between two views is measured from the last baseline of the top view to the top of the bottom view
@property (nonatomic, assign) BOOL baselineRelativeArrangementDeclared In
ASStackLayoutSpec.h
+ stackLayoutSpecWithDirection:spacing:justifyContent:alignItems:children:
The direction of the stack view (horizontal or vertical)
+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray<id<ASLayoutElement> > *)childrenParameters
direction |
The direction of the stack view (horizontal or vertical) |
|---|---|
spacing |
The spacing between the children |
justifyContent |
If no children are flexible, this describes how to fill any extra space |
alignItems |
Orientation of the children along the cross axis |
children |
ASLayoutElement children to be positioned. |
Declared In
ASStackLayoutSpec.h
+ verticalStackLayoutSpec
A stack layout spec with direction of ASStackLayoutDirectionVertical
+ (instancetype)verticalStackLayoutSpecReturn Value
A stack layout spec with direction of ASStackLayoutDirectionVertical
Declared In
ASStackLayoutSpec.h
+ horizontalStackLayoutSpec
A stack layout spec with direction of ASStackLayoutDirectionHorizontal
+ (instancetype)horizontalStackLayoutSpecReturn Value
A stack layout spec with direction of ASStackLayoutDirectionHorizontal
Declared In
ASStackLayoutSpec.h