title: SFSafariViewController: Hide navigation bar
body: <p>I was able to get my app to automatically load a url via the SFSafariViewController per this <a href="https://stackoverflow.com/questions/33809985/xcode-7-swift-automatically-load-site-via-sfsafariviewcontroller">post</a>, and it works great, the only drawback is the navbar. </p>
  
  <p>The SFSafariViewController navbar is kind of useless when being used this way, as the url is read-only, and the 'done' link doesn't do anything but reload the page. As such, I would like to hide the navbar altogether.</p>
  
  <p>Per the comments attached to accepted answer, it was suggested to set my root view controller to SFSafariViewController which I can't get working. The setup is simple as there is a single view controller with the code included in the aforementioned post.</p>
  
  <p>How can I hide the navbar but still maintain the benefits of the SFSafariViewController? Or if I can't hide the navbar, at least hide the 'done' link?</p>
  
  <p>Code snippet:</p>
  
  <pre><code>import UIKit
  import SafariServices
  
  class ViewController: UIViewController
  {
      private var urlString:String = "https://example.com"
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
      }
  
      override func viewDidAppear(animated: Bool)
      {
  
          super.viewDidAppear(animated)
  
          let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)
  
          self.presentViewController(svc, animated: true, completion: nil)
  
          self.navigationItem.rightBarButtonItem = nil
      }
  
      override func didReceiveMemoryWarning()
      {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  }
  </code></pre>
  
  <p>----- Works. Navbar is "hidden" -----</p>
  
  <pre><code>import UIKit
  import SafariServices
  
  class ViewController: UIViewController
  {
      private var urlString:String = "https://example.com"
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          // This will remove the status (battery, time, etc) bar
          UIApplication.sharedApplication().statusBarHidden = true
      }
  
      override func viewDidAppear(animated: Bool) {
  
          super.viewDidAppear(animated)
  
          let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)
  
          // Kind of a hack, in that we really aren't removing the navbar
          //  Rather we are adjusting the starting point of the vpc object so it appears as the navbar is hidden
          self.presentViewController(svc, animated: true) {
  
              var frame = svc.view.frame
              let OffsetY: CGFloat = 42
  
              frame.origin = CGPoint(x: frame.origin.x, y: frame.origin.y - OffsetY)
              frame.size = CGSize(width: frame.size.width, height: frame.size.height + OffsetY)
              svc.view.frame = frame
          }
      }
  
      override func didReceiveMemoryWarning()
      {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      // For this to work be sure to set the following setting to OFF, in info.plist
      //  'View controller-based status bar appearance'
      override func prefersStatusBarHidden() -&gt; Bool {
          return true
      }
  }
  </code></pre>