Can not create OAStackView programmatically
Closed this issue · 2 comments
skagedal commented
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.