Skip to content

Commit

Permalink
Reset main screen after keyboard disappears
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Liu committed Mar 11, 2022
1 parent d4c1730 commit 458dcd3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions WordleWithFriends/GameSetupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,13 @@ final class GameSetupViewController: UIViewController {
let keyboardRect = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let keyboardFrame = view.convert(keyboardRect, from: view.window)

scrollView.contentInset.top = -keyboardFrame.height / 2
scrollView.contentInset.bottom = keyboardFrame.height / 2
if notification.name == UIResponder.keyboardWillShowNotification {
scrollView.contentInset.top = -keyboardFrame.height / 2
scrollView.contentInset.bottom = keyboardFrame.height / 2
} else {
scrollView.contentInset.top = 0
scrollView.contentInset.bottom = 0
}
}

@objc private func openSettings() {
Expand Down

0 comments on commit 458dcd3

Please sign in to comment.