title: How to make image weight and height fill screen in Swift Xcode?
body: <p>I found a code to make slide in swift, but cant find, h<strong>ow to make the IMAGE fill the whole screen.</strong>
  Could you help?</p>
  
  <p>here is the screenshot of slider, and you will see the anchors I placed on it to show you, the whole screen.</p>
  
  <p><a href="https://i.stack.imgur.com/pRvoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pRvoG.png" alt="enter image description here"></a></p>
  
  <p><strong>and here is the code of it;</strong></p>
  
  <pre><code>import UIKit
  class OnboardingController: UIViewController, UIScrollViewDelegate {
      let backgroundColor = UIColor(red: 241.0/255.0, green: 196.0/255.0, blue: 15.0/255.0, alpha: 1.0)
      let slides = [
          [ "image": "book4page1.png"],
          [ "image": "book4page2.png"],
          [ "image": "book4page3.png"],
      ]
      let screen: CGRect = UIScreen.mainScreen().bounds
      var scroll: UIScrollView?
      var dots: UIPageControl?
      override func viewDidLoad() {
          super.viewDidLoad()
          view.backgroundColor = backgroundColor
          scroll = UIScrollView(frame: CGRect(x: 0.0, y: 0.0, width: screen.width, height: screen.height * 0.9))
          scroll?.showsHorizontalScrollIndicator = false
          scroll?.showsVerticalScrollIndicator = false
          scroll?.pagingEnabled = true
          view.addSubview(scroll!)
          if (slides.count &gt; 1) {
              dots = UIPageControl(frame: CGRect(x: 0.0, y: screen.height * 0.875, width: screen.width, height: screen.height * 0.05))
              dots?.numberOfPages = slides.count
              view.addSubview(dots!)
          }
          for var i = 0; i &lt; slides.count; ++i {
              if let image = UIImage(named: slides[i]["image"]!) {
                  let imageView: UIImageView = UIImageView(frame: getFrame(image.size.width, iH: image.size.height, slide: i, offset: screen.height * 0.15))
                  imageView.image = image
                  scroll?.addSubview(imageView)
              }
              if let text = slides[i]["text"] {
                  let textView = UITextView(frame: CGRect(x: screen.width * 0.05 + CGFloat(i) * screen.width, y: screen.height * 0.745, width: screen.width * 0.9, height: 100.0))
                  textView.text = text
                  textView.editable = false
                  textView.selectable = false
                  textView.textAlignment = NSTextAlignment.Center
                  textView.font = UIFont.systemFontOfSize(20, weight: 0)
                  textView.textColor = UIColor.whiteColor()
                  textView.backgroundColor = UIColor.clearColor()
                  scroll?.addSubview(textView)
              }
          }
          scroll?.contentSize = CGSizeMake(CGFloat(Int(screen.width) *  slides.count), screen.height * 0.5)
          scroll?.delegate = self
          dots?.addTarget(self, action: Selector("swipe:"), forControlEvents: UIControlEvents.ValueChanged)
          let closeButton = UIButton()
          closeButton.frame = CGRect(x: screen.width - 70, y: 20, width: 60, height: 60)
          closeButton.setTitle("Skip", forState: .Normal)
          closeButton.setTitleColor(UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 0.5), forState: .Normal)
          closeButton.titleLabel!.font =  UIFont.systemFontOfSize(16)
          closeButton.addTarget(self, action: "pressed:", forControlEvents: .TouchUpInside)
          view.addSubview(closeButton)
      }
      func pressed(sender: UIButton!) {
          self.dismissViewControllerAnimated(true) { () -&gt; Void in
          }
      }
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
      func getFrame (iW: CGFloat, iH: CGFloat, slide: Int, offset: CGFloat) -&gt; CGRect {
          let mH: CGFloat = screen.height * 0.50
          let mW: CGFloat = screen.width
          var h: CGFloat
          var w: CGFloat
          let r = iW / iH
          if (r &lt;= 1) {
              h = min(mH, iH)
              w = h * r
          } else {
              w = min(mW, iW)
              h = w / r
          }
          return CGRectMake(
              max(0, (mW - w) / 2) + CGFloat(slide) * screen.width,
              max(0, (mH - h) / 2) + offset,
              w,
              h
          )
      }
      func swipe(sender: AnyObject) -&gt; () {
          if let scrollView = scroll {
              let x = CGFloat(dots!.currentPage) * scrollView.frame.size.width
              scroll?.setContentOffset(CGPointMake(x, 0), animated: true)
          }
      }
      func scrollViewDidEndDecelerating(scrollView: UIScrollView) -&gt; () {
          let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
          dots!.currentPage = Int(pageNumber)
      }
      override func preferredStatusBarStyle() -&gt; UIStatusBarStyle {
          return UIStatusBarStyle.LightContent
      }
  }
  </code></pre>