1

I have a UITextView in my ViewController. I resize programmatically his height to the content by this code (found on SO) :

let fixedWidth = textView.frame.size.width
textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
var newFrame = textView.frame
newFrame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)
textView.frame = newFrame

The problem is : when the user edits the TextView, I would like the text to move to the top, instead of moving to the bottom. Anyone could help me please ?

An example : enter image description here

Community
  • 1
  • 1

0 Answers0