title: make image view full screen in view controller/page view controller (swift)
body: <p>I am using UIPageViewController to show images full screen.  Issue is the images are not showing full screen. Instead there is a gap on the bottom between the image and the page control view dots and on the top. I have a UIViewController which is added to UIPageController as a sub view / child and that ViewController has the images being showed using ImageView. I am trying to do this in swift/storyboard.</p>
  
  <p>I changing the top bar and bottom bar option to "none" in storyboard, but it didn't work.</p>
  
  <p>Image Preview:</p>
  
  <p><img src="https://i.stack.imgur.com/2tLNu.png" alt="enter image description here"></p>
  
  <p>The ChildViewControllerCode:</p>
  
  <pre><code>class BoatContentViewController: UIViewController {
  
  @IBOutlet weak var imageView: UIImageView!
  @IBOutlet weak var titleLabel: UILabel!
  
  
  var pageIndex: Int!
  var titleText: String!
  var imageFile: String!
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.imageView.image = UIImage(named: self.imageFile)
      self.titleLabel.text = self.titleText
  
  
      // Do any additional setup after loading the view.
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  </code></pre>
  
  <p>The mainViewControllerCode:</p>
  
  <pre><code>class BoatViewController: UIViewController, UIPageViewControllerDataSource {
  @IBOutlet weak var loginButton: UIButton!
  @IBOutlet weak var skipButton: UIButton!
  
  var pageViewController: UIPageViewController!
  var pageTitles: NSArray!
  var pageImages: NSArray!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      loginButton.backgroundColor = UIColor.clearColor()
      loginButton.layer.cornerRadius = 5
      loginButton.layer.borderWidth = 1
      loginButton.layer.borderColor = UIColor.purpleColor().CGColor
  
  
      skipButton.backgroundColor = UIColor.whiteColor()
      skipButton.layer.cornerRadius = 5
      skipButton.layer.borderWidth = 1
      skipButton.layer.borderColor = UIColor.whiteColor().CGColor
  
  
      self.pageTitles = NSArray(objects: "", "", "", "", "")
      self.pageImages = NSArray(objects: "onboarding1", "onboarding2", "onboarding3", "onboarding4", "onboarding5")
      self.pageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("BoatPageViewController") as! UIPageViewController
      self.pageViewController.dataSource = self
      var startVC = self.viewControllerAtIndex(0) as BoatContentViewController
      var viewControllers = NSArray(object: startVC)
      self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)
      self.pageViewController.view.frame = CGRectMake(0, 30, self.view.frame.width, self.view.frame.size.height - 60)
      self.addChildViewController(self.pageViewController)
      self.view.addSubview(self.pageViewController.view)
      self.pageViewController.didMoveToParentViewController(self)
  
      // Do any additional setup after loading the view.
  }
  
  func viewControllerAtIndex(index: Int) -&gt; BoatContentViewController {
  
      if ((self.pageTitles.count == 0) || (index &gt;= self.pageTitles.count)) {
  
          return BoatContentViewController()
  
      }
  
  
      var vc: BoatContentViewController = self.storyboard?.instantiateViewControllerWithIdentifier("BoatContentViewController") as! BoatContentViewController
  
      vc.imageFile = self.pageImages[index] as! String
  
      vc.titleText = self.pageTitles[index]as! String
  
      vc.pageIndex = index
  
      return vc
  }
  
  func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController?
  
  {
  
      var vc = viewController as! BoatContentViewController
  
      var index = vc.pageIndex as Int
  
      if (index == 0 || index == NSNotFound)
  
      {
          return nil
  
      }
  
      index--
  
      return self.viewControllerAtIndex(index)
  
  }
  
  
  
  func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
  
      var vc = viewController as! BoatContentViewController
  
      var index = vc.pageIndex as Int
  
      if (index == NSNotFound) {
          return nil
      }
  
      index++
  
      if (index == self.pageTitles.count) {
          return nil
      }
  
      return self.viewControllerAtIndex(index)
  
  }
  
  func presentationCountForPageViewController(pageViewController: UIPageViewController) -&gt; Int {
      return self.pageTitles.count
  }
  
  
  func presentationIndexForPageViewController(pageViewController: UIPageViewController) -&gt; Int {
      return 0
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  </code></pre>
  
  <p>App Delegate:</p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
      // Override point for customization after application launch.
  
  
  
      var pageControl = UIPageControl.appearance()
  
      pageControl.pageIndicatorTintColor = UIColor.lightGrayColor()
  
      pageControl.currentPageIndicatorTintColor = UIColor.blackColor()
  
      pageControl.backgroundColor = UIColor.clearColor()
  
  
  
      return true
  }
  </code></pre>