title: Taking screenshot using Swift 5 returns a black image and not the app's screen
body: <p>I'm trying to take a screenshot of my app and then share it.</p>
  
  <p>The problem I'm having is that when I take a screenshot and save it to the Photos app, the image that gets saved is completely black (and not the screenshot of my app).</p>
  
  <p>How can I get the screenshot to be of my app? What am I missing?</p>
  
  <pre><code>func takeScreenshot() {
          let bounds = UIScreen.main.bounds
          UIGraphicsBeginImageContextWithOptions(bounds.size, true, 0.0)
          self.view.drawHierarchy(in: bounds, afterScreenUpdates: false)
          let img = UIGraphicsGetImageFromCurrentImageContext()
          UIGraphicsEndImageContext()
          let activityViewController = UIActivityViewController(activityItems: [img!], applicationActivities: nil)
          self.present(activityViewController, animated: true, completion: nil)
      }
  </code></pre>
  
  <p>App is a single screen.<br>
  Swift 5<br>
  xCode 10</p>
  
  <p>I've tried browsing other similar StackOverflow issues and tweaking my code to theirs but getting the same results. Hitting a wall and trying here.</p>
  
  <p>Thanks for any help!</p>
  
  <p><a href="https://i.stack.imgur.com/qUfw2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qUfw2.png" alt="View Controller Scene"></a></p>