 private var ckmHiddenRegular: UInt8 = 2
 private var ckmHiddenCompact: UInt8 = 3
 extension UIView {
-    
+
     fileprivate var shownRegularConstraints: [Constraint]! {
         get { return objc_getAssociatedObject(self, &ckmShownRegular) as? [Constraint] ?? [Constraint]() }
         set(newValue) { objc_setAssociatedObject(self, &ckmShownRegular, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) }
     }
-    
+
     fileprivate var shownCompactConstraints: [Constraint]! {
         get { return objc_getAssociatedObject(self, &ckmShownCompact) as? [Constraint] ?? [Constraint]() }
         set(newValue) { objc_setAssociatedObject(self, &ckmShownCompact, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) }

        get { return objc_getAssociatedObject(self, &ckmHiddenRegular) as? [Constraint] ?? [Constraint]() }
        set(newValue) { objc_setAssociatedObject(self, &ckmHiddenRegular, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) }
    }
    
    fileprivate var hiddenCompactConstraints: [Constraint]! {
        get { return objc_getAssociatedObject(self, &ckmHiddenCompact) as? [Constraint] ?? [Constraint]() }
        set(newValue) { objc_setAssociatedObject(self, &ckmHiddenCompact, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) }
    }
    
    private dynamic func keyboardWillShow(notification: Notification){
        let duration = (notification as NSNotification).userInfo![UIKeyboardAnimationDurationUserInfoKey] as! TimeInterval
        let option = (notification as NSNotification).userInfo![UIKeyboardAnimationCurveUserInfoKey] as! NSNumber
        
        switch traitCollection.verticalSizeClass {
        case .regular:
            hiddenRegularConstraints.forEach { $0.deactivate() }

            hiddenCompactConstraints.forEach { $0.activate() }
        case .unspecified: break
        }

        UIView.animate(withDuration: duration, delay: 0,
                       options: UIView.AnimationOptions(rawValue: option.uintValue), animations: {
                        self.layoutIfNeeded()
        }, completion: nil)
    }

    func registerAutomaticKeyboardConstraints() {
        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
    }
}

