         let options = UIViewAnimationOptions(rawValue: UInt((notification.userInfo?[UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).integerValue << 16))
         let duration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey]?.doubleValue
         if frame != nil && duration != nil {
-            self.onKeyboardIsBeingShown?()
             UIView.animateWithDuration(
                 duration!,
                 delay: 0,
                 options: options,
                 animations: { () -> Void in
+                    self.onKeyboardIsBeingShown?()
                     self.constraint.constant = frame!.size.height + self.offset
                     self.view.layoutIfNeeded()
                 },

        let options = UIViewAnimationOptions(rawValue: UInt((notification.userInfo?[UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).integerValue << 16))
        let duration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey]?.doubleValue
        if frame != nil && duration != nil {
            UIView.animateWithDuration(duration!, delay: 0, options: options, animations: { () -> Void in
                self.constraint.constant = self.offset
                self.view.layoutIfNeeded()
            }, completion: nil)
        }
    }
}

    public var onKeyboardIsBeingShown: (() -> ())?
    public var onKeyboardWasShown: (() -> ())?
    public var onKeyboardIsBeingHidden: (() -> ())?
    public var onKeyboardWasHidden: (() -> ())?

    override public func awakeFromNib() {
        super.awakeFromNib()
