skip to Main Content

I am using a view inside a scrollview and inside the view, there are two labels with fixed width. and I want to make these labels auto-resizing in respect of height. For this I have given the height of the view >= but it’s breaking the constraints. How can I achieve auto resizing content within scrollview.
enter image description here

3

Answers


  1. First, you need a content view inside the scroll that has constraints with the controller’s view (equally both width and height) and top, leading, trailing, bottom with scroll view.

    Then, add any subviews inside that content view. In your case is the label’s bound view.

    Something like:

    • The red one is the content of your scroll view
    • The gray one is bound label view

    enter image description here

    Login or Signup to reply.
  2. Just embed all these labels in stack view. And that’s it.
    enter image description here

    enter image description here

    Login or Signup to reply.
  3. While using scrollview it’s mandatory to give the height of the elements inside scrollview. But if we want to make an element self height adjusting then we can give the minimum height with the priority 250
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search