Don_Mag icon

Untitled

Don_Mag | PRO | 12/05/21 03:49:14 PM UTC | 0 ⭐ | 10599 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

 
- (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],
        
    ]];
 
}
 
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎