I have a UITextView, with a height constraint in order to adapt the height of the frame to its content (depending of the length of the string). (I use autolayout). It works fine.
But, I don't understand something about the size of the textview frame.
I explain.
I display the frame infos after setting the text of the uitextview, and after updating the constraint.
override func viewDidLoad() {
...
self.textview.text = post.title
...
}
override func viewDidLayoutSubviews() {
let contentSize = self.textview.sizeThatFits(self.textview.bounds.size)
self.heightConstraint.constant = contentSize.height
self.textview.layoutIfNeeded()
print(self.textview.frame) // frame
print(self.textview.bounds) // bounds
}
The result:
For case A:
(8.0, 0.0, 584.0, 97.0) //frame
(0.0, 0.0, 584.0, 97.0) //bounds
For case B:
(8.0, 0.0, 584.0, 97.0) //frame
(0.0, 0.0, 584.0, 97.0) //bounds
I don't understand why the height of the frame is the same in both case???