OAStackView icon indicating copy to clipboard operation
OAStackView copied to clipboard

Something different between OAStackView and UIStackView

Open nerdycat opened this issue 10 years ago • 0 comments

  • (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

nerdycat avatar Dec 21 '15 11:12 nerdycat