title: iOS Swift: Hide and unhide Nav and tool bars
body: <p>Experts,</p>
  
  <p>I am using following code to hide the tool and nav bars before capturing the screen view. However the image still shows both bars...what I'am I doing wrong?</p>
  
  <pre><code>func generateMeme() -&gt;UIImage {
          // Hide toolbar and navbar
          self.navigationController?.navigationBarHidden = true
          self.navigationController?.toolbarHidden = true
  
          // Render view to an image
          UIGraphicsBeginImageContext(self.view.frame.size)
          self.view.drawViewHierarchyInRect(self.view.frame,afterScreenUpdates:true)
          let memedImage : UIImage = UIGraphicsGetImageFromCurrentImageContext()
          UIGraphicsEndImageContext()
  
          // Show toolbar and navbar
          self.navigationController?.navigationBarHidden = true
          self.navigationController?.toolbarHidden = true
  
          return memedImage
      }
  </code></pre>
  
  <p>Thanks</p>