title: How to align UIImageView with Aspect Fit to Top?
body: <p>I'm working on some screen in which at top I have an application logo: I want this logo to be resized based on the free size it has. So I configured it with the desired constraints and when it has enough space it like the desired result:</p>
  
  <p><a href="https://i.stack.imgur.com/3pAXc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3pAXc.png" alt="enter image description here"></a></p>
  
  <p>The problem starts when the <code>UIImageView</code> does not have enough space to spread in this case the image is centred in the <code>UIImageView</code> and leaves an empty space above it:</p>
  
  <p><a href="https://i.stack.imgur.com/mYMuA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mYMuA.png" alt="enter image description here"></a></p>
  
  <p>Now I tried to place the <code>UIImageView</code> inside a simple <code>UIView</code> and place it accordingly inside, but so far without result.</p>
  
  <p>I also tried to search for an answer here but all the solutions I have found:</p>
  
  <p><a href="https://stackoverflow.com/questions/12711133/how-to-set-image-in-top-avoiding-space-in-uiimageview">how to set image in top avoiding space in UIimageView</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3272335/alignment-uiimageview-with-aspect-fit">Alignment UIImageView with Aspect Fit</a></p>
  
  <p>and a custom view:</p>
  
  <p><a href="https://github.com/reydanro/UIImageViewAligned" rel="nofollow noreferrer">https://github.com/reydanro/UIImageViewAligned</a></p>
  
  <p>were in Objective-C when I'm using Swift. How can I achieve this using the <code>Storyboard</code> on Swift?</p>