     
     // MARK: Managing Arranged Views
     
+    /**
+    Adds a view to the end of the arrangedSubviews array.
+    
+    The stack view ensures that the arrangedSubviews array is always a subset of its subviews array. This method automatically adds the provided view as a subview of the stack view, if it is not already. If the view is already a subview, this operation does not alter the subview ordering.
+    */
     public func addArrangedSubview(view: UIView) {
         insertArrangedSubview(view, atIndex: arrangedSubviews.count)
     }
-
+    
+    /**
+     Removes the provided view from the stack’s array of arranged subviews.
+     
+     This method removes the provided view from the stack’s arrangedSubviews array. The view’s position and size will no longer be managed by the stack view. However, this method does not remove the provided view from the stack’s subviews array; therefore, the view is still displayed as part of the view hierarchy.
+     */
     public func removeArrangedSubview(view: UIView) {
         if let index = arrangedSubviews.indexOf(view) {
             arrangedSubviews.removeAtIndex(index)


import UIKit

public enum StackViewDistribution {
    case Fill
    case FillEqually
    case FillProportionally
    case EqualSpacing
    case EqualCentering
}

public enum StackViewAlignment {
    case Fill
    case Leading
    public static var Top: StackViewAlignment {
        return .Leading
    }
    case Center
    case Trailing
    public static var Bottom: StackViewAlignment {
        return .Trailing
    }
    case FirstBaseline
    case LastBaseline
}

public class StackView : UIView {
    public var axis: UILayoutConstraintAxis = .Horizontal {
        didSet { if axis != oldValue { invalidateLayout() } }
    }
    public var distribution: StackViewDistribution = .Fill {
        didSet { if distribution != oldValue { invalidateLayout() } }
    }
    public var alignment: StackViewAlignment = .Fill {
        didSet { if alignment != oldValue { invalidateLayout() } }
    }
    public var spacing: CGFloat = 0.0 {
        didSet { if spacing != oldValue { invalidateLayout() } }
    }
    public var baselineRelativeArrangement = false {
        didSet { if baselineRelativeArrangement != oldValue { invalidateLayout() } }
    }
    public var layoutMarginsRelativeArrangement = false {
        didSet { if layoutMarginsRelativeArrangement != oldValue { invalidateLayout() } }
    }
    
    private var alignmentArrangement: AlignedLayoutArrangement!
    private var distributionArrangement: DistributionLayoutArrangement!

    private var invalidated = false

    public private(set) var arrangedSubviews = [UIView]()
    private var hiddenViews = Set<UIView>()
    
    public init(arrangedSubviews views: [UIView]) {
        super.init(frame: CGRectZero)
        commonInit(views: views)
    }

    public convenience init() {
        self.init(arrangedSubviews: [])
    }
    
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit(views: subviews)
    }
    
    private func commonInit(views views: [UIView]) {

        }
    }
    
    /**
     Adds the provided view to the array of arranged subviews at the specified index.
     
     If index is already occupied, the stack view increases the size of the arrangedSubviews array and shifts all of its contents at the index and above to the next higher space in the array. Then the stack view stores the provided view at the index.
     
     The stack view also ensures that the arrangedSubviews array is always a subset of its subviews array. This method automatically adds the provided view as a subview of the stack view, if it is not already. When adding subviews, the stack view appends the view to the end of its subviews array. The index only affects the order of views in the arrangedSubviews array. It does not affect the ordering of views in the subviews array.
     */
    public func insertArrangedSubview(view: UIView, atIndex stackIndex: Int) {
        if !arrangedSubviews.contains(view) {
            view.translatesAutoresizingMaskIntoConstraints = false
