Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)viewDidLoad {
- [super viewDidLoad];
- UIStackView *stack = [UIStackView new];
- stack.distribution = UIStackViewDistributionFillEqually;
- stack.spacing = 8;
- UILabel *v1 = [UILabel new];
- v1.backgroundColor = [UIColor cyanColor];
- v1.textAlignment = NSTextAlignmentCenter;
- v1.numberOfLines = 0;
- v1.text = @"One Line";
- UILabel *v2 = [UILabel new];
- v2.backgroundColor = [UIColor greenColor];
- v2.textAlignment = NSTextAlignmentCenter;
- v2.numberOfLines = 0;
- v2.text = @"Lots of text to force the label to wrap onto multiple lines.";
- [stack addArrangedSubview:v1];
- [stack addArrangedSubview:v2];
- stack.translatesAutoresizingMaskIntoConstraints = NO;
- [self.view addSubview:stack];
- [NSLayoutConstraint activateConstraints:@[
- [stack.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:20.0],
- [stack.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor constant:-20.0],
- [stack.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor constant:-20.0],
- ]];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement