         self.setupGroupViews()
 
         self.cancelGroupView.removeConstraints(self.cancelControlConstraints)
-        self.cancelControlConstraints = self.constraintsForControls(self.cancelControls)
+        self.cancelControlConstraints = self.constraintsForViews(self.cancelControls)
         self.cancelGroupView.addConstraints(self.cancelControlConstraints)
         self.actionGroupView.removeConstraints(self.actionControlConstraints)
-        self.actionControlConstraints = self.constraintsForControls(self.actionControls)
+        self.actionControlConstraints = self.constraintsForViews(self.actionControlsWithTitle())
         self.actionGroupView.addConstraints(self.actionControlConstraints)
     }
 

        )
    }

    private func constraintsForControls(controls: [UIControl]) -> [NSLayoutConstraint] {
        var constraints: [NSLayoutConstraint] = []

        var sibling: UIControl?
        for control in controls {
            let isLast = control == controls.last
            constraints.appendContentsOf(self.horizontalConstraintsForControl(control))
            constraints.appendContentsOf(self.verticalConstraintsForControl(control, isLast: isLast, sibling: sibling))

            sibling = control
        }
        
        return constraints
    }

    private func horizontalConstraintsForControl(control: UIControl) -> [NSLayoutConstraint] {
        return NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[control]-0-|",
            options: .DirectionLeadingToTrailing,
            metrics: nil,
            views: ["control": control]) 
    }

    private func verticalConstraintsForControl(control: UIControl, isLast: Bool, sibling: UIControl?) -> [NSLayoutConstraint] {
        var constraints: [NSLayoutConstraint] = []
        if let sibling = sibling {
            constraints.appendContentsOf(NSLayoutConstraint.constraintsWithVisualFormat("V:[control(height)]-spacing-[sibling]",
                options: .DirectionLeadingToTrailing,
                metrics: ["spacing": self.spacing, "height": self.controlHeight],
                views: ["control": control, "sibling": sibling]) )
        } else {
            constraints.appendContentsOf(NSLayoutConstraint.constraintsWithVisualFormat("V:[control(height)]-0-|",
                options: .DirectionLeadingToTrailing,
                metrics: ["height": self.controlHeight],
                views: ["control": control]) )
        }
        if isLast {
            constraints.appendContentsOf(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[control(height)]",
                options: .DirectionLeadingToTrailing,
                metrics: ["height": self.controlHeight],
                views: ["control": control]) )
        }
        return constraints
    }

        if isCancelAction {
            self.cancelGroupView.addSubview(control)
            self.cancelGroupView.removeConstraints(self.cancelControlConstraints)
            self.cancelControlConstraints = self.constraintsForViews(self.cancelControls)
            self.cancelGroupView.addConstraints(self.cancelControlConstraints)
        } else {
            self.actionGroupView.addSubview(control)
            self.actionGroupView.removeConstraints(self.actionControlConstraints)
            self.actionControlConstraints = self.constraintsForViews(self.actionControlsWithTitle())
            self.actionGroupView.addConstraints(self.actionControlConstraints)
        }
    }

    public func addTitle(title: String) {
        let label = UILabel.titleWithText(title)
        self.addTitleView(label)
    }

    public func addTitleView(titleView: UIView) {
        self.titleView = titleView

        self.titleView!.translatesAutoresizingMaskIntoConstraints = false
        self.actionGroupView.addSubview(self.titleView!)
        self.actionGroupView.removeConstraints(self.actionControlConstraints)
        self.actionControlConstraints = self.constraintsForViews(self.actionControlsWithTitle())
        self.actionGroupView.addConstraints(self.actionControlConstraints)
    }

    private func actionControlsWithTitle() -> [UIView] {
        var views: [UIView] = self.actionControls
        if let titleView = self.titleView {
            views.append(titleView)
        }
        return views
    }


