Multiline label in UIStackView

The correct answer is here: https://stackoverflow.com/a/43110590/566360 Embed the UILabel inside a UIView (Editor -> Embed In -> View) Use constraints to fit the UILabel to the UIView (for example, trailing space, top space, and leading space to superview constraints) The UIStackView will stretch out the UIView to fit properly, and the UIView will constrain the … Read more

UIStackView Hide View Animation

Just had the same issue. The fix is adding stackView.layoutIfNeeded() inside the animation block. Where stackView is the container of the items you’re wishing to hide. UIView.animate(withDuration: DiscoverHeaderView.animationDuration, delay: 0.0, usingSpringWithDamping: 0.9, initialSpringVelocity: 1, options: [], animations: { clear.isHidden = hideClear useMyLocation.isHidden = hideLocation stackView.layoutIfNeeded() }, completion: nil) Not sure why this is suddenly an … Read more

Add views in UIStackView programmatically

Stack views use intrinsic content size, so use layout constraints to define the dimensions of the views. There is an easy way to add constraints quickly (example): [view1.heightAnchor constraintEqualToConstant:100].active = true; Complete Code: – (void) setup { //View 1 UIView *view1 = [[UIView alloc] init]; view1.backgroundColor = [UIColor blueColor]; [view1.heightAnchor constraintEqualToConstant:100].active = true; [view1.widthAnchor constraintEqualToConstant:120].active … Read more