title: How to make a square view resize with its superview using auto layout
body: <p>In my particular case I have view inside the view controller for which I added the following constraints:</p>
  
  <ul>
  <li>Set leading, trailing, top and bottom edges to 0</li>
  <li>Set multiplier to bottom edge to 2:1</li>
  </ul>
  
  <p>Now the view sits in the top half on the view controller.  </p>
  
  <p>Inside this I add a square image view, for which I added the following constraints:</p>
  
  <ul>
  <li>Ctrl drag from image view to superview and added equal heights and widths.</li>
  <li>Change the multiplier for width and height until I have a perfect square.</li>
  <li>Added constraints to be center vertically and horizontally</li>
  </ul>
  
  <p>My constraints seems perfect, but when running in the simulator I don't get a perfect square. Besides this, the image view doesn't get resize when running on different simulator screens.  </p>
  
  <p>This is my setup:  </p>
  
  <ul>
  <li>Auto layout and size classes are enabled</li>
  <li>I use an Inferred size for the storyboard</li>
  <li>Adaptive layout is set to Any for width and height</li>
  <li>I am trying to run this for the 4s,5,6 and 6+ simulators.  </li>
  </ul>
  
  <p>I looked on other stackoverflow posts, but nothing seems to work.  </p>
  
  <p>Are there some basic steps to do this ?</p>
  
  <p><a href="https://i.stack.imgur.com/ZvDRr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZvDRr.png" alt="enter image description here"></a></p>
  
  <p>edit:</p>
  
  <p>After setting >=10 constraints: </p>
  
  <p><a href="https://i.stack.imgur.com/2G1uk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2G1uk.png" alt="enter image description here"></a></p>
  
  <p>edit 3: I added top,bottom,leading,trailing constraints 2 times, 1 with lower than or equal(priority 1000), the other one with greater than or equal(priority 800) with the constant value of 90. I don't know why for bottom it tries to streches to 90 pt from the main view, not the container view(green one).</p>
  
  <p><a href="https://i.stack.imgur.com/JHHeV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JHHeV.png" alt="enter image description here"></a></p>