To adjust the position of the UITextView when the keyboard will show in Swift, you can follow these steps:
UIKeyboardWillShowNotification and UIKeyboardWillHideNotification in your view controller’s viewDidLoad() method.main.swift385 chars7 lineskeyboardWillShow(notification:), retrieve the keyboard height and adjust the bottom constraint of your UITextView.main.swift321 chars7 lineskeyboardWillHide(notification:), reset the bottom constraint of your UITextView.main.swift126 chars4 linesUITextView is pinned to the bottom of the screen with a constraint (e.g., textViewBottomConstraint).You can also adjust the position of other UI elements when the keyboard is shown by changing their constraints in the keyboardWillShow(notification:) method. And don't forget to remove the notification observers when the view controller is deallocated:
main.swift63 chars4 lines
gistlibby LogSnag