nsomar/OAStackView

Can not create OAStackView programmatically

Closed this issue · 2 comments

The following simple View Controller works perfectly with an UIStackView, and creates a red box on top of a green box:

- (void)viewDidLoad {
    self.edgesForExtendedLayout = UIRectEdgeNone;

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

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

    stackView.axis = UILayoutConstraintAxisVertical;
    stackView.distribution = OAStackViewDistributionFillEqually;
    stackView.alignment = OAStackViewAlignmentFill;
    stackView.spacing = 0.0;

    UIView *redView = [UIView new];
    redView.translatesAutoresizingMaskIntoConstraints = NO;
    redView.backgroundColor = [UIColor redColor];
    [stackView addArrangedSubview:redView];

    UIView *greenView = [UIView new];
    greenView.translatesAutoresizingMaskIntoConstraints = NO;
    greenView.backgroundColor = [UIColor greenColor];
    [stackView addArrangedSubview:greenView];
}

However, the same code but replacing UIStackView with OAStackview, UIStackViewDistributionFillEqually with OAStackViewDistributionFillEqually and UIStackViewAlignmentFill with OAStackViewAlignmentFill gives me nothing - shows just the black background.

@skagedal I've tried your snippet and it works for me as expected, can you try it again using HEAD version?
pod 'OAStackView', :head

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