 
     func keyboardFrameChanged(notification: NSNotification) {
         if let userInfo = notification.userInfo {
-            let frame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
+            let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
             textInputBar.frame.origin.y = frame.origin.y
         }
     }
     
     func keyboardWillShow(notification: NSNotification) {
         if let userInfo = notification.userInfo {
-            let frame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
+            let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
             textInputBar.frame.origin.y = frame.origin.y
         }
     }
     
     func keyboardWillHide(notification: NSNotification) {
         if let userInfo = notification.userInfo {
-            let frame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
+            let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
             textInputBar.frame.origin.y = frame.origin.y
         }
     }

        
        configureScrollView()
        configureInputBar()
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardFrameChanged(_:)), name: ALKeyboardFrameDidChangeNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardWillShow(_:)), name: UIKeyboardWillShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: nil)
    }

    override func viewWillLayoutSubviews() {

    func configureScrollView() {
        view.addSubview(scrollView)
        
        let contentView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.size.width, height: view.bounds.size.height * 2))
        contentView.backgroundColor = UIColor(white: 0.8, alpha: 1)
        
        scrollView.addSubview(contentView)
        scrollView.contentSize = contentView.bounds.size
        scrollView.keyboardDismissMode = .interactive
        scrollView.backgroundColor = UIColor(white: 0.6, alpha: 1)
    }
    
    func configureInputBar() {
        let leftButton  = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
        let rightButton = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
        
        leftButton.setImage(#imageLiteral(resourceName: "leftIcon"), for: .normal)
        rightButton.setImage(#imageLiteral(resourceName: "rightIcon"), for: .normal)
        
        keyboardObserver.isUserInteractionEnabled = false
        
        textInputBar.showTextViewBorder = true
        textInputBar.leftView = leftButton
        textInputBar.rightView = rightButton
        textInputBar.frame = CGRect(x: 0, y: view.frame.size.height - textInputBar.defaultHeight, width: view.frame.size.width, height: textInputBar.defaultHeight)
        textInputBar.backgroundColor = UIColor(white: 0.95, alpha: 1)
        textInputBar.keyboardObserver = keyboardObserver
        
