title: How to set full width image inside UIScrollView in swift
body: <p>I need to display large content in my <code>UIViewController</code> added in Storyboard so I added <code>UIScrollView</code> with constraints top, right, bottom, left:0 ( to make it full screen ).</p>
  
  <p>In top of <code>UIScrollView</code> I need a square image with its width as device screen size, so I added <code>UIImageView</code> with constraints : aspect ratio->1:1, top:0, centre align in container, height : 100.
  And below It there is a <code>UILabel</code> where I want to show large text. I am using Auto Layout.</p>
  
  <ol>
  <li>Is there an option to do this in Storyboard ?</li>
  <li>In swift I tried below</li>
  </ol>
  
  <p>Connected Image in controller file as : </p>
  
  <pre><code>@IBOutlet weak var eventThumb: UIImageView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // set image path from url ,it works
      eventThumb.image = UIImage(data: NSData(contentsOfURL: NSURL(string: self.event!.image)!)!) 
  
      let screenSize: CGRect = UIScreen.mainScreen().bounds
      eventThumb.frame = CGRectMake( 0,  0,  screenSize.width,  screenSize.width)
  
  }
  </code></pre>
  
  <p>I tried related answers given <a href="https://stackoverflow.com/questions/29455694/uiimageview-programmatically-in-swift">here</a> ,<a href="https://stackoverflow.com/questions/31345903/programmatically-change-the-height-and-width-of-a-uiimageview-xcode-swift">here</a> and <a href="https://stackoverflow.com/questions/25773527/how-to-scale-a-uiimage-view-to-a-square-with-autolayout-inside-a-uiscrollview">here</a> but they not seem to working in my case. </p>
  
  <p>I am new in swift and ios, am I doing something wrong in structure ?</p>
  
  <p>Edit :
  Image added </p>
  
  <p><a href="https://i.stack.imgur.com/n9g17.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n9g17.png" alt="enter image description here"></a></p>