dimgl dimgl - 1 year ago 189
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download