0
votes

How can I get a UILabel with a variable number of lines to push down the content in a UIScrollView?

enter image description here

I currently have a UIScrollView pinned to the superview, a container inside pinned to scrollview and equal height/width to main view, and this blue UIView (height 50), 2 UILabels and a UIImageView (height 200) inside the container.

In landscape I want the UIImageView (i.e. black box of height 200) to not be pinned to the bottom of the superview, but be offscreen and the scrollview content size to have been adjusted.

In portrait I want the labels to size to fit and the black box to respect the top constraint to the bottom label:

enter image description here

1

1 Answers

0
votes

Tried more stuff and the following worked:

  1. set both labels' vertical resistance to 1000

  2. delete the "equal height" constraint on the container

So the solution to seems to be:

  1. add a scrollview and pin all edges to vc's view
  2. add container to scrollview, pin all edges to scrollview, equal width to vc's view (height varies based on bottom pinning to content), add all content to container