UIStackView

public extension UIStackView
  • SwifterSwift: Initialize an UIStackView with an array of UIView and common parameters.

    let stackView = UIStackView(arrangedSubviews: [UIView(), UIView()], axis: .vertical)
    

    Declaration

    Swift

    convenience init(
        arrangedSubviews: [UIView],
        axis: NSLayoutConstraint.Axis,
        spacing: CGFloat = 0.0,
        alignment: UIStackView.Alignment = .fill,
        distribution: UIStackView.Distribution = .fill)

    Parameters

    arrangedSubviews

    The UIViews to add to the stack.

    axis

    The axis along which the arranged views are laid out.

    spacing

    The distance in points between the adjacent edges of the stack view’s arranged views.(default: 0.0)

    alignment

    The alignment of the arranged subviews perpendicular to the stack view’s axis. (default: .fill)

    distribution

    The distribution of the arranged views along the stack view’s axis.(default: .fill)

  • SwifterSwift: Adds array of views to the end of the arrangedSubviews array.

    Declaration

    Swift

    func addArrangedSubviews(_ views: [UIView])

    Parameters

    views

    views array.

  • SwifterSwift: Removes all views in stack’s array of arranged subviews.

    Declaration

    Swift

    func removeArrangedSubviews()