dimgl dimgl - 2 months ago 17x
Swift Question

Set frame height to zero in a UITextView

I'm having trouble setting the height for a

frame completely to zero even when it contains no text. Here's what it looks like (the red is the

I've tried setting the frame's height to zero from my code as well.

var frame = bodyTextView.frame
frame.size.height = 0
bodyTextView.frame = frame

My labels can have a frame height of zero but this
just won't get smaller than the line height.


Are you using auto-layout or size classes ? If not use…

bodyTextView.frame = CGRectMake(bodyTextView.frame.origin.x, bodyTextView.frame.origin.y, bodyTextView.frame.size.width, 0)  

If you using auto-layout, then you should set up a height constraint on bodyTextView and use…

heightConstraintBodyTextView.constraint = 0