Created
March 20, 2018 17:26
-
-
Save projectxcappe/5a41c5b14ab495df67d7821e89b76d45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Method just for getting keyboard height | |
| @objc func keyboardWillShow(_ notification: Notification) { | |
| if let keyboardFrame: NSValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue { | |
| let keyboardRectangle = keyboardFrame.cgRectValue | |
| keyboardHeight = keyboardRectangle.height | |
| } | |
| } | |
| func checkIfKeyboardIsOverTextField(keyboardHeight: CGFloat) { | |
| for field in textfieldCollection { | |
| if (field.isFirstResponder) { | |
| print((field.frame.origin.y + field.frame.size.height)) | |
| print(keyboardHeight) | |
| if (field.frame.origin.y + field.frame.size.height) >= keyboardHeight { | |
| scrollView.setContentOffset(CGPoint(x:0.0,y:100), animated: true) | |
| } | |
| } | |
| } | |
| } | |
| func textFieldDidBeginEditing(_ textField: UITextField) { | |
| checkIfKeyboardIsOverTextField(keyboardHeight: keyboardHeight) | |
| // if textField.frame.origin.y <= keyboardHeight { | |
| // scrollView.setContentOffset(CGPoint(x:0.0,y:100), animated: true) | |
| // } | |
| // fadeOut(labelCollection: labelCollection) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment