Reputation: 2491
I have a GrowingTextView
which increases its height when content size increases.
override viewDidLoad() {
tv.translatesAutoresizingMaskIntoConstraints = false
tvHeight.constant = 200
tv.sizeToFit()
}
func textViewDidChange(_ textView: UITextView) {
if textView.contentSize.height > 200 {
textView.sizeToFit()
}
updateScroll()
}
I want to set minimum height to the text view as 200, but it is not working. I tried in IB as well as code. The UI has the below components each with 16 as leading and trailing and 8 as top and bottom constraints.
UITextField - Title
GrowingTextView - tv
UITextField - Author
UITextField
How to set the min height for text view?
Upvotes: 0
Views: 2217
Reputation: 422
Using the library that you mentioned GrowingTextView
in your comment you can use the parameter minHeight = 200
.
tv.minHeight = 200
In that case I think you don't need the height constant tvHeight.constant = 200
. Here is an example:
override viewDidLoad() {
super.viewDidLoad()
tv.translatesAutoresizingMaskIntoConstraints = false
tv.minHeight = 200
tv.sizeToFit()
}
Upvotes: 2