Welcome to a fun and easy introduction to app development with SwiftUI! This tutorial will…
How to scroll to the top of UITextView ( Swift )
In this tutorial, we will disclose a simple thing: How to scroll to the top of UITextView using Swift:
Let’s say you have a ViewController and the UITextView variable named textView.
Add self.textView.setContentOffset(.zero, animated: true) to viewDidAppear method in your ViewController
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.textView.setContentOffset(.zero, animated: true)
}
Don’t forget to subscribe to AppMakers.Dev mailing list if you love this content and want to stay tuned with recent iOS Development news, tutorials and resources.
Keep in mind that at the moment of writing this post we used Xcode 10 and Swift 5.
If anything will change in the future, it is OK, just use the new API calls or check the Documentation.