diff --git a/Classes/Views/Universal/StackView.swift b/Classes/Views/Universal/StackView.swift index 99c65b7..441495c 100644 --- a/Classes/Views/Universal/StackView.swift +++ b/Classes/Views/Universal/StackView.swift @@ -89,6 +89,7 @@ open class _StackView: _STV, AnyDeclarativeProtocol, DeclarativeProtocolInternal var __bottom: State { _bottom } var __centerX: State { _centerX } var __centerY: State { _centerY } + private var nestedStackViews: [WeakBox] = [] open override var tag: Int { get { properties.tag } @@ -154,6 +155,9 @@ open class _StackView: _STV, AnyDeclarativeProtocol, DeclarativeProtocolInternal @discardableResult public func alignment(_ alignment: UIStackView.Alignment) -> Self { self.alignment = alignment + for view in nestedStackViews { + view.underlying?.alignment = alignment + } return self } #endif @@ -163,14 +167,21 @@ open class _StackView: _STV, AnyDeclarativeProtocol, DeclarativeProtocolInternal @discardableResult public func distribution(_ distribution: _STV.Distribution) -> Self { self.distribution = distribution + + for view in nestedStackViews { + view.underlying?.distribution = distribution + } return self } - + // Mask: Spacing @discardableResult public func spacing(_ spacing: CGFloat) -> Self { self.spacing = spacing + for view in nestedStackViews { + view.underlying?.spacing = spacing + } return self } @@ -195,9 +206,7 @@ open class _StackView: _STV, AnyDeclarativeProtocol, DeclarativeProtocolInternal #else let stack = UStackView().axis(fr.axis ?? axis) #endif - stack.distribution(distribution) - .alignment(alignment) - .spacing(spacing) + nestedStackViews.append(WeakBox(stack)) fr.allItems().forEach { #if os(macOS) stack.addArrangedSubview([$0].flatten(fr.orientation ?? orientation))