         }
     }
 }
-

        let frame = self.frame ?? CGRectMake(0, 0, 38, 38)
        var buttonCustomView: UIView
        if let text = self.text {
            let label = UILabel(frame: frame)
            label.backgroundColor = UIColor.clearColor()
            label.textColor = self.tintColor
            label.font = self.font ?? UIFont.systemFontOfSize(UIFont.buttonFontSize())
            label.text = text
            label.textAlignment = .Center
            label.minimumScaleFactor = 0.2
            label.adjustsFontSizeToFitWidth = true
            buttonCustomView = label
        } else {
            let imageView = UIImageView(frame: frame)
            imageView.backgroundColor = UIColor.clearColor()
            imageView.image = icon
            imageView.contentMode = self.contentMode ?? .ScaleAspectFit
            imageView.tintColor = tintColor
            buttonCustomView = imageView
        }
        
        let button = UIButton(type: UIButtonType.Custom)
        button.frame = frame
        button.layer.cornerRadius = 5
        button.layer.borderWidth = 0
        button.addSubview(buttonCustomView)
        button.addTarget(self, action: #selector(tapAction(_:)), forControlEvents: .TouchUpInside)
        button.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.fullscreenLayoutForView(viewToLayout: buttonCustomView, inView: button)
        button.setNeedsUpdateConstraints()
        button.setNeedsLayout()
        button.setNeedsDisplay()

        self.icon = icon
        commonInit()
        
    }
    
    public init(icon: UIImage?, contentMode: UIViewContentMode, callback: (animatedBarButtonItem: CDAnimatedBarButtonItem?) -> Void) {
        super.init()
        onTapCallback = callback
        self.icon = icon
        commonInit()
        self.contentMode = contentMode
    }
    
    public init(options: CDAnimatedBarButtonItemOptions) {
        super.init()
        commonInit()
        self.options = options
    }
    
    public func commonInit() {
