ASLayoutOptions Class Reference
| Inherits from | NSObject |
|---|---|
| Conforms to | ASStackLayoutable ASStaticLayoutable NSCopying |
| Declared in | ASLayoutOptions.h |
Overview
A store for all of the options defined by ASLayoutSpec subclasses. All implementors of ASLayoutable own a ASLayoutOptions. When certain layoutSpecs need option values, they are read from this class.
Unless you wish to create a custom layout spec, ASLayoutOptions can largerly be ignored. Instead you can access the layout option properties exposed in ASLayoutable directly, which will set the values in ASLayoutOptions behind the scenes.
+ setDefaultLayoutOptionsClass:
Sets the class name for the ASLayoutOptions subclasses that will be created when a node or layoutSpec’s options are first accessed.
+ (void)setDefaultLayoutOptionsClass:(Class)defaultLayoutOptionsClassParameters
defaultLayoutOptionsClass |
The class of ASLayoutOptions that will be lazily created for a node or layout spec. |
|---|
Discussion
If you create a custom layoutSpec that includes new options, you will want to subclass ASLayoutOptions to add the new layout options for your layoutSpec(s). In order to make sure your subclass is created instead of an instance of ASLayoutOptions, call setDefaultLayoutOptionsClass: early in app launch (applicationDidFinishLaunching:) with your subclass’s class.
Declared In
ASLayoutOptions.h
+ defaultLayoutOptionsClass
the Class of ASLayoutOptions that will be created for a node or layoutspec. Defaults to [ASLayoutOptions class];
+ (Class)defaultLayoutOptionsClassReturn Value
the Class of ASLayoutOptions that will be created for a node or layoutspec. Defaults to [ASLayoutOptions class];
Declared In
ASLayoutOptions.h
– initWithLayoutable:
Initializes a new ASLayoutOptions using the given layoutable to assign any intrinsic option values. This init function sets a sensible default value for each layout option. If you create a subclass of ASLayoutOptions, your subclass should do the same.
- (instancetype)initWithLayoutable:(id<ASLayoutable>)layoutableParameters
layoutable |
The layoutable that will own these options. The layoutable will be used to set any intrinsic layoutOptions. For example, if the layoutable is an ASTextNode the ascender/descender values will get set. |
|---|
Return Value
a new instance of ASLayoutOptions
Declared In
ASLayoutOptions.h
– copyIntoOptions:
Copies the values of layoutOptions into self. This is useful when placing a layoutable inside of another. Consider an ASTextNode that you want to align to the baseline by putting it in an ASStackLayoutSpec. Before that, you want to inset the ASTextNode by placing it in an ASInsetLayoutSpec. An ASInsetLayoutSpec will not have any information about the ASTextNode’s ascender/descender unless we copy over the layout options from ASTextNode to ASInsetLayoutSpec. This is done automatically and should not need to be called directly. It is listed here to make sure that any ASLayoutOptions subclass implements the method.
- (void)copyIntoOptions:(ASLayoutOptions *)layoutOptionsParameters
layoutOptions |
The layoutOptions to copy from |
|---|
Declared In
ASLayoutOptions.h
spacingBefore
Additional space to place before this object in the stacking direction. Used when attached to a stack layout.
@property (nonatomic, readwrite) CGFloat spacingBeforeDeclared In
ASStackLayoutable.h
spacingAfter
Additional space to place after this object in the stacking direction. Used when attached to a stack layout.
@property (nonatomic, readwrite) CGFloat spacingAfterDeclared In
ASStackLayoutable.h
flexGrow
If the sum of childrens' stack dimensions is less than the minimum size, should this object grow? Used when attached to a stack layout.
@property (nonatomic, readwrite) BOOL flexGrowDeclared In
ASStackLayoutable.h
flexShrink
If the sum of childrens' stack dimensions is greater than the maximum size, should this object shrink? Used when attached to a stack layout.
@property (nonatomic, readwrite) BOOL flexShrinkDeclared In
ASStackLayoutable.h
flexBasis
Specifies the initial size in the stack dimension for this object. Default to ASRelativeDimensionUnconstrained. Used when attached to a stack layout.
@property (nonatomic, readwrite) ASRelativeDimension flexBasisDeclared In
ASStackLayoutable.h
alignSelf
Orientation of the object along cross axis, overriding alignItems Used when attached to a stack layout.
@property (nonatomic, readwrite) ASStackLayoutAlignSelf alignSelfDeclared In
ASStackLayoutable.h
ascender
Used for baseline alignment. The distance from the top of the object to its baseline.
@property (nonatomic, readwrite) CGFloat ascenderDeclared In
ASStackLayoutable.h
descender
Used for baseline alignment. The distance from the baseline of the object to its bottom.
@property (nonatomic, readwrite) CGFloat descenderDeclared In
ASStackLayoutable.h
sizeRange
If specified, the child’s size is restricted according to this size. Percentages are resolved relative to the static layout spec.
@property (nonatomic, readwrite) ASRelativeSizeRange sizeRangeDeclared In
ASStaticLayoutable.h
layoutPosition
The position of this object within its parent spec.
@property (nonatomic, readwrite) CGPoint layoutPositionDeclared In
ASStaticLayoutable.h