Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center Aligned View Width #40

Closed
calebd opened this issue Aug 20, 2015 · 5 comments
Closed

Center Aligned View Width #40

calebd opened this issue Aug 20, 2015 · 5 comments

Comments

@calebd
Copy link
Contributor

calebd commented Aug 20, 2015

Center aligned views are allowed to be wider than the stack view. It would be great if stack view added a width constraint to views such that they may not be wider than the stack view itself.

Also it would be cool if we can get another tagged, stable release!

@mthole-old
Copy link

@calebd Can you confirm that UIStackView on iOS 9 has the behavior your describe/desire?

@calebd
Copy link
Contributor Author

calebd commented Aug 24, 2015

#42

@calebd
Copy link
Contributor Author

calebd commented Aug 24, 2015

UIStackView does not let center aligned views go wider than the stack view itself. Why would it allow that?

A quick test: Put a multi line label with a lot of text in a width-constrained, center-aligned stack view. Notice that the stack view height grows while restricting the label to its width.

@delebedev
Copy link
Collaborator

@calebd can you please check 0.2.0 tag, it works the same way as OAStackView for me (tried to reproduce your setup:

    OAStackView *stackView = [OAStackView new];
    stackView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:stackView];

    UILayoutGuide *margin = self.view.layoutMarginsGuide;
    [stackView.topAnchor constraintEqualToAnchor:margin.topAnchor constant:16.0].active = YES;
    [stackView.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor constant:50].active = YES;
    //[stackView.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor constant:-16.0].active = YES;
    [stackView.trailingAnchor constraintEqualToAnchor:margin.trailingAnchor constant:-50].active = YES;

    stackView.axis = UILayoutConstraintAxisVertical;
    stackView.distribution = UIStackViewDistributionFill;
    stackView.alignment = UIStackViewAlignmentCenter;
    stackView.spacing = 0.0;

    UIView *redView = [UIView new];
    redView.translatesAutoresizingMaskIntoConstraints = NO;
    redView.backgroundColor = [UIColor redColor];
    [redView.heightAnchor constraintEqualToConstant:100].active = YES;
    [redView.widthAnchor constraintEqualToConstant:50].active = YES;

    UILabel *text = [[UILabel alloc] init];
    text.text = @"ofofo ofofo ofofoof ofof ofofo fofo ofofo ofofofo ofofof ofofofo ofofofo ofofofo ofo foofo fo";
    text.numberOfLines = 0;

    [stackView addArrangedSubview:text];
    [stackView addArrangedSubview:redView];

@nsomar
Copy link
Owner

nsomar commented Nov 24, 2015

@calebd I am closing this issue since there have been no feedback from your side.
Please feel free to reopen it if the issue persists.

@nsomar nsomar closed this as completed Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants