ASLayout Class Reference

Inherits from NSObject
Declared in ASLayout.h

Overview

Represents a computed immutable layout tree.

  position

Position in parent. Default to CGPointNull.

@property (nonatomic, readwrite) 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, readonly) NSArray *sublayouts

Declared In

ASLayout.h

+ layoutWithLayoutableObject:size:position:sublayouts:

Initializer.

+ (instancetype)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject size:(CGSize)size position:(CGPoint)position sublayouts:(NSArray *)sublayouts

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

position

The posiion of this layout within its parent (if available).

sublayouts

Sublayouts belong to the new layout.

Declared In

ASLayout.h

+ layoutWithLayoutableObject: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)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject size:(CGSize)size sublayouts:(NSArray *)sublayouts

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

sublayouts

Sublayouts belong to the new layout.

Declared In

ASLayout.h

+ layoutWithLayoutableObject: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)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject size:(CGSize)size

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

Declared In

ASLayout.h

– flattenedLayoutUsingPredicateBlock:

Evaluates a given predicate block against each object in the receiving layout tree and returns a new, 1-level deep layout containing the objects for which the predicate block returns true.

- (ASLayout *)flattenedLayoutUsingPredicateBlock:(BOOL ( ^ ) ( ASLayout *evaluatedLayout ))predicateBlock

Parameters

predicateBlock

The block is applied to a layout to be evaluated. The block takes 1 argument: evaluatedLayout - the layout to be evaluated. The block returns YES if evaluatedLayout evaluates to true, otherwise NO.

Return Value

A new, 1-level deep layout containing the layouts for which the predicate block returns true.

Declared In

ASLayout.h