Uistackview

UI StackView

Implementation

Programmatically

SO

Article

Hidden gems of UIStackView

Distribution Types

Animating subview

Custom UI Elements on StackView

Documentation

Apple Developer

Debug

Errors:

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x600001575e00 "UIButton:0x7fafea124c50.centerX"> and <NSLayoutXAxisAnchor:0x600001570980 "UIView:0x7fafdffa97f0.centerX"> because they have no common ancestor.  Does the constraint or its anchors reference items in different view hierarchies?  That's illegal.'
terminating with uncaught exception of type NSException

Constraint common view hierarchy error.

UIView Events

If you're embeding UIstackView in a UIView class and are not able to get some event responses, you need disable its user interaction flag.

class CustomView: UIButton {
	init() {
        super.init(frame: .zero)
		labelStackView.addArrangedSubviews(titleStackView, descriptionLabel)
        addSubview(labelStackView)
    }
    
	private(set) var labelStackView: UIStackView = {
		stackView.isUserInteractionEnabled = false
	}