Skip to content

[ASLayoutSpec] How enforce maximum width (or height) {answer: ASStaticLayoutSpec} #124

Open
@garrettmoon

Description

@garrettmoon

From @eanagel on February 23, 2016 20:31

Also published in StackOverflow

I'm trying to enforce a maximum height for an element and I can't figure out exactly which LayoutSpec can help me do that. It seems like the sizeRange property is what I would expect to work but that appears to work only with ASStaticLayoutSpec, which seems like more of a last resort option. (This element I need to constrain is contained in an ASInsetLayoutSpec in my case.)

Here's my attempt:

        CGSize max = CGSizeMake(constrainedSize.max.width, [self.class maxSinglePhotoHeight]);
        _singlePhotoNode.sizeRange = ASRelativeSizeRangeMake(ASRelativeSizeMakeWithCGSize(constrainedSize.min), ASRelativeSizeMakeWithCGSize(max));
        ASInsetLayoutSpec *inset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:PHOTO_INSET child:_singlePhotoNode];

Copied from original issue: facebookarchive/AsyncDisplayKit#1264

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions