I know that there is automatic scrolling when the content(text) exceeds the default height of the text view, but I want the text view to be full screen and when the content comes to the keyboard level, the text view should scroll automatically. I have given a GIF to help readers understand better.
class StartStoryPopUp: UIViewController, UITextViewDelegate {
// Setup text view
func setupTextView() {
textViewOne.textColor = .black
textViewOne.backgroundColor = baseColor
// Add some padding to the text insde the text view
textViewOne.textContainerInset = UIEdgeInsets(top: 15, left: 10, bottom: 15, right: 10)
textViewOne.font = UIFont(name: "PatrickHand-Regular", size: 25)
textViewOne.layer.cornerRadius = 25
popUp.addSubview(textViewOne)
addTextViewConstraints()
}
// Add the constraints to the 'start story' text view
func addTextViewConstraints() {
textViewOne.translatesAutoresizingMaskIntoConstraints = false
textViewOne.leadingAnchor.constraint(equalTo: popUp.leadingAnchor, constant: 3).isActive = true
textViewOne.trailingAnchor.constraint(equalTo: popUp.trailingAnchor, constant: -3).isActive = true
textViewOne.topAnchor.constraint(equalTo: popUp.topAnchor, constant: 3).isActive = true
textViewOne.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -30).isActive = true
}
}