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

Something different between OAStackView and UIStackView #71

Open
nerdycat opened this issue Dec 21, 2015 · 0 comments
Open

Something different between OAStackView and UIStackView #71

nerdycat opened this issue Dec 21, 2015 · 0 comments

Comments

@nerdycat
Copy link

  • (void)viewDidLoad {
    [super viewDidLoad];

    UILabel *label1 = [UILabel new];
    UILabel *label2 = [UILabel new];
    label1.text = @"Some long text!!!";
    label2.text = @"ABC";

    OAStackView *sv = [[OAStackView alloc] initWithArrangedSubviews:@[label1, label2]];
    sv.translatesAutoresizingMaskIntoConstraints = NO;
    sv.axis = UILayoutConstraintAxisHorizontal;
    sv.alignment = OAStackViewAlignmentTop;
    sv.distribution = OAStackViewDistributionEqualSpacing;

    [self.view addSubview:sv];

    [sv.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:50].active = YES;
    [sv.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:10].active = YES;
    [sv.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-10].active = YES;

    UILabel *label3 = [UILabel new];
    UILabel *label4 = [UILabel new];
    label3.text = @"Some long text!!!";
    label4.text = @"ABC";

    UIStackView *sv2 = [[UIStackView alloc] initWithArrangedSubviews:@[label3, label4]];
    sv2.translatesAutoresizingMaskIntoConstraints = NO;
    sv2.axis = UILayoutConstraintAxisHorizontal;
    sv2.alignment = OAStackViewAlignmentTop;
    sv2.distribution = OAStackViewDistributionEqualSpacing;

    [self.view addSubview:sv2];

    [sv2.topAnchor constraintEqualToAnchor:sv.bottomAnchor constant:50].active = YES;
    [sv2.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:10].active = YES;
    [sv2.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-10].active = YES;
    }

The codes are very similar, one for OAStackView, one for UIStackView. The result is different, the label1 get clipped and label3 is fine.

img_6194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant