ASLayout Class Reference
Inherits from | NSObject |
---|---|
Declared in | ASLayout.h |
Overview
A node in the layout tree that represents the size and position of the object that created it (ASLayoutElement).
layoutElement
The underlying object described by this layout
@property (nonatomic, weak, readonly) id<ASLayoutElement> layoutElement
Declared In
ASLayout.h
type
The type of ASLayoutElement that created this layout
@property (nonatomic, assign, readonly) ASLayoutElementType type
Declared In
ASLayout.h
size
Size of the current layout
@property (nonatomic, assign, readonly) CGSize size
Declared In
ASLayout.h
position
Position in parent. Default to CGPointNull.
@property (nonatomic, assign, readonly) CGPoint position
Discussion
When being used as a sublayout, this property must not equal CGPointNull.
Declared In
ASLayout.h
sublayouts
Array of ASLayouts. Each must have a valid non-null position.
@property (nonatomic, copy, readonly) NSArray<ASLayout*> *sublayouts
Declared In
ASLayout.h
frame
Returns a valid frame for the current layout computed with the size and position.
@property (nonatomic, assign, readonly) CGRect frame
Discussion
Clamps the layout’s origin or position to 0 if any of the calculated values are infinite.
Declared In
ASLayout.h
– initWithLayoutElement:size:position:sublayouts:
Designated initializer
- (instancetype)initWithLayoutElement:(id<ASLayoutElement>)layoutElement size:(CGSize)size position:(CGPoint)position sublayouts:(nullable NSArray<ASLayout*> *)sublayouts
Declared In
ASLayout.h
+ layoutWithLayoutElement:size:position:sublayouts:
Convenience class initializer for layout construction.
+ (instancetype)layoutWithLayoutElement:(id<ASLayoutElement>)layoutElement size:(CGSize)size position:(CGPoint)position sublayouts:(nullable NSArray<ASLayout*> *)sublayouts
Parameters
layoutElement |
The backing ASLayoutElement object. |
---|---|
size |
The size of this layout. |
position |
The position of this layout within its parent (if available). |
sublayouts |
Sublayouts belong to the new layout. |
Declared In
ASLayout.h
+ layoutWithLayoutElement:size:sublayouts:
Convenience initializer that has CGPointNull position. Best used by ASDisplayNode subclasses that are manually creating a layout for -calculateLayoutThatFits:, or for ASLayoutSpec subclasses that are referencing the “self” level in the layout tree, or for creating a sublayout of which the position is yet to be determined.
+ (instancetype)layoutWithLayoutElement:(id<ASLayoutElement>)layoutElement size:(CGSize)size sublayouts:(nullable NSArray<ASLayout*> *)sublayouts
Parameters
layoutElement |
The backing ASLayoutElement object. |
---|---|
size |
The size of this layout. |
sublayouts |
Sublayouts belong to the new layout. |
Declared In
ASLayout.h
+ layoutWithLayoutElement:size:
Convenience that has CGPointNull position and no sublayouts. Best used for creating a layout that has no sublayouts, and is either a root one or a sublayout of which the position is yet to be determined.
+ (instancetype)layoutWithLayoutElement:(id<ASLayoutElement>)layoutElement size:(CGSize)size
Parameters
layoutElement |
The backing ASLayoutElement object. |
---|---|
size |
The size of this layout. |
Declared In
ASLayout.h
+ layoutWithLayout:position:
Convenience initializer that creates a layout based on the values of the given layout, with a new position
+ (instancetype)layoutWithLayout:(ASLayout *)layout position:(CGPoint)position
Parameters
layout |
The layout to use to create the new layout |
---|---|
position |
The position of the new layout |
Declared In
ASLayout.h
– filteredNodeLayoutTree
Traverses the existing layout tree and generates a new tree that represents only ASDisplayNode layouts
- (ASLayout *)filteredNodeLayoutTree
Declared In
ASLayout.h