Skip to content

Instantly share code, notes, and snippets.

@hcn1519
Created March 4, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hcn1519/b55b0741cd6fc1b64e0723321faa1395 to your computer and use it in GitHub Desktop.
Save hcn1519/b55b0741cd6fc1b64e0723321faa1395 to your computer and use it in GitHub Desktop.
class VC: ViewController {
var keyboardVisible = true
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@objc func keyboardWillShow(notification: NSNotification) {
// 여기서 키보 높이 받을 수 있어
let userInfo = notification.userInfo ?? [:]
let keyboardFrame = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
// do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment