Skip to content

Instantly share code, notes, and snippets.

@zontan
Created September 9, 2020 17:54
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 zontan/41e59cca8da22d0dd40c460d92db16fc to your computer and use it in GitHub Desktop.
Save zontan/41e59cca8da22d0dd40c460d92db16fc to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
messageList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "chatCell", for: indexPath)
let message = messageList[indexPath.row]
cell.textLabel?.text = message
cell.textLabel?.numberOfLines = 0
cell.backgroundColor = .clear
cell.textLabel?.textColor = .systemBlue
return cell
}
@objc func keyboardWillShow(notification: NSNotification) {
guard let userInfo = notification.userInfo else { return }
guard let keyboardSize = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
let keyboardFrame = keyboardSize.cgRectValue
bottomConstraint?.constant = 20 + keyboardFrame.height
}
@objc func keyboardWillHide(notification: NSNotification) {
bottomConstraint?.constant = 110
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment