How to auto calculate container size based on its content ? #756

Closed
opened 2018-04-23 09:28:27 -07:00 by Anonymous-fe · 1 comment
Anonymous-fe commented 2018-04-23 09:28:27 -07:00 (Migrated from github.com)

Report

Issues and Steps to Reproduce

// ... in config method
[self configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
        layout.isEnabled = YES;
        layout.flexDirection = YGFlexDirectionColumn;
        layout.justifyContent = YGJustifyFlexStart;
        layout.alignItems = YGAlignStretch;
    }];

    UILabel *label = [UILabel new];
    label.text = @"just A test title for label";
    [label configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
        layout.isEnabled = YES;
        layout.marginLeft = YGPointValue(10);
        layout.marginRight = YGPointValue(10);
        layout.marginBottom = YGPointValue(4);
    }];
    [self addSubview:label];
// ... end config

- (void)layoutSubviews {
    [super layoutSubviews];

    [self.yoga applyLayoutPreservingOrigin:NO];
}


// in viewcontroller's viewWillLayoutSubviews
view.frame = self.view.bounds;

Expected Behavior

I hope my view could resize itself based on its content, not use the size I assigned with 'view.frame'

Any help? Thanks

# Report - [*] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # Issues and Steps to Reproduce ``` objc // ... in config method [self configureLayoutWithBlock:^(YGLayout * _Nonnull layout) { layout.isEnabled = YES; layout.flexDirection = YGFlexDirectionColumn; layout.justifyContent = YGJustifyFlexStart; layout.alignItems = YGAlignStretch; }]; UILabel *label = [UILabel new]; label.text = @"just A test title for label"; [label configureLayoutWithBlock:^(YGLayout * _Nonnull layout) { layout.isEnabled = YES; layout.marginLeft = YGPointValue(10); layout.marginRight = YGPointValue(10); layout.marginBottom = YGPointValue(4); }]; [self addSubview:label]; // ... end config - (void)layoutSubviews { [super layoutSubviews]; [self.yoga applyLayoutPreservingOrigin:NO]; } // in viewcontroller's viewWillLayoutSubviews view.frame = self.view.bounds; ``` # Expected Behavior I hope my view could resize itself based on its content, not use the size I assigned with 'view.frame' Any help? Thanks
NickGerleman commented 2023-06-13 08:06:08 -07:00 (Migrated from github.com)

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#756
No description provided.