Skip to content

Instantly share code, notes, and snippets.

@ratulSharker
Created April 22, 2018 09:47
Show Gist options
  • Save ratulSharker/e64295fde9b5a8fe16764edc03ae2e08 to your computer and use it in GitHub Desktop.
Save ratulSharker/e64295fde9b5a8fe16764edc03ae2e08 to your computer and use it in GitHub Desktop.
This gist set's all the padding and inset to zero, so that UITextView is ready to wrap the content in it.
import UIKit
extension UITextView {
func wrapToContent() {
self.contentInset = UIEdgeInsets.zero
self.scrollIndicatorInsets = UIEdgeInsets.zero
self.contentOffset = CGPoint.zero
self.textContainerInset = UIEdgeInsets.zero
self.textContainer.lineFragmentPadding = 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment