         }
     }
     
+    public var delegate :CRDropdownAlertDelegate?
+    
     // MARK: - Initialization
     
     convenience public init() {

import UIKit
import pop

/// Inspired by: https://github.com/cwRichardKim/RKDropdownAlert and https://github.com/startupthekid/DropdownAlert/
public class CRDropdownAlert: UIView {
    
    // MARK: - Animation
    

     Common initialization function.
     */
    func commonInit() {
        self.titleText.font = Defaults.TitleFont
        self.messageLabel.font = Defaults.MessageFont
        
        self.addSubview(self.titleText)
        self.addSubview(self.messageLabel)
        self.setupConstraints()
        
        self.addTarget(self, action: #selector(CRDropdownAlert.viewWasTapped(alertView:)), for: .touchUpInside);
    }
    
    @objc
    private func viewWasTapped(alertView :UIView) {
        
        if let delegate = self.delegate {
            if delegate.dropdownAlertWasTapped(alert: self) {
                self.dismiss();
            }
        } else {
            self.dismiss();
        }
    }
    
    /**
     Setup the constraints for the dropdown's labels.
     */
    private func setupConstraints() {
        self.addConstraint(NSLayoutConstraint(item: self.titleText, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0))
        self.addConstraint(NSLayoutConstraint(item: self.titleText, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0))
        self.addConstraint(NSLayoutConstraint(item: self.titleText, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1, constant: 0))
        
        self.addConstraint(NSLayoutConstraint(item: self.messageLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0))
        self.addConstraint(NSLayoutConstraint(item: self.messageLabel, attribute: .top, relatedBy: .equal, toItem: self.titleText, attribute: .bottom, multiplier: 1, constant: Defaults.VerticalPadding))
        self.addConstraint(NSLayoutConstraint(item: self.messageLabel, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1, constant: -Defaults.VerticalPadding))
        self.addConstraint(NSLayoutConstraint(item: self.messageLabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1, constant: 0))
        
