skip to Main Content

I have 3 elements, imageview, label and a view. I want to maintain the eqaul space (15) for bottom view. Layout is as :
Imageview then label and at the bottom, there is a view. I have defined the top constraints of the view >=15 from the imageview, 84 from label but I want to push down the view when the label grows beyond the imgeview. Now what is happening the view is pushing down when the lable gets on new line and there is more than 15pt space between label and the bottom view which I don’t want.
enter image description here

2

Answers


  1. This is the screenshot for storyboard.

    This is from simulator running app with label smaller than image.

    This is from simulator running app with label greater than image pushing bottom view.

    1. This is the screenshot for storyboard.
    2. This is from simulator running app with label smaller than image.
    3. This is from simulator running app with label greater than image pushing bottom view.
    Login or Signup to reply.
  2. Probably the easiest way is to put the image view and label in a horizontal stack view, with Alignment set to Top:

    enter image description here

    enter image description here

    The stack view is constrained at 16-pts Top / Leading / Trailing, and 15-pts to the "blue view."

    At run-time, with different amounts of text in the label:

    enter image description here

    enter image description here

    enter image description here

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