     
     override func updateView() {
         super.updateView()
-        button0?.setTitle(displayedButton0Title, forState: .Normal)
+        for action in actions {
+            action.button?.setTitle(action.title, forState: .Normal)
+        }
         hideUnused()
     }
     

        }
    }
    
    @IBInspectable var button0Title: String? {
        didSet {
            setNeedsUpdateView()
        }
    }

    @IBInspectable var button1Title: String? {
        get {
            return button1?.titleForState(.Normal)
        }
        set {
            button1?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }

    @IBInspectable var button2Title: String? {
        get {
            return button2?.titleForState(.Normal)
        }
        set {
            button2?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }

    @IBInspectable var button3Title: String? {
        get {
            return button3?.titleForState(.Normal)
        }
        set {
            button3?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }
    
    @IBInspectable var button4Title: String? {
        get {
            return button4?.titleForState(.Normal)
        }
        set {
            button4?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }
    
    @IBInspectable var button5Title: String? {
        get {
            return button5?.titleForState(.Normal)
        }
        set {
            button5?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }
    
    @IBInspectable var button6Title: String? {
        get {
            return button6?.titleForState(.Normal)
        }
        set {
            button6?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }
    
    @IBInspectable var button7Title: String? {
        get {
            return button7?.titleForState(.Normal)
        }
        set {
            button7?.setTitle(newValue, forState: .Normal)
            setNeedsUpdateView()
        }
    }
    
    @IBInspectable var maxHorizontalButtonTitleCharacterCount: Int = 9 {
        didSet {

    
    // MARK: - Private variables and functions

    typealias Action = (button: UIButton?, title: String?)
    
    private var displayedButton0Title: String {
        return button0Title ?? (hasCancel ? ButtonTitle.cancel : ButtonTitle.ok)
    }
    
    private var bottomActions: [Action] {
        return [
            (button0, displayedButton0Title),
            (button1, button1Title)
        ]
    }
    private var topActions: [Action] {
        return [
            (button2, button2Title),
            (button3, button3Title),
            (button4, button4Title),
            (button5, button5Title),
            (button6, button6Title),
            (button7, button7Title)
        ]
    }
    
    private var actions: [Action] {
        return bottomActions + topActions
    }
    
    private var buttons: [UIButton] {
        return actions.flatMap { $0.button }
    }
    
    private var isHorizontalLayout: Bool {
        let hasTopTitles = topActions.flatMap { $0.title }.count > 0
        let hasShortBottomTitles = bottomActions.filter { $0.title?.characters.count <= maxHorizontalButtonTitleCharacterCount }.count == 2
        return hasShortBottomTitles && !hasTopTitles
    }
    
    private func hideUnused() {
        for action in actions {
            action.button?.hidden = action.title == nil || isPlaceholderString(action.title)
        }
        messageLabel?.activateOnlyConstraintsWithFirstVisibleInViews(buttons.reverse())
        if let horizontalButtonsLayoutConstraints = horizontalButtonsLayoutConstraints,
