Edit: Thus, the following works in the simulator, but does not work on the device. I'm currently looking for a solution.
You cannot get only the visible area of ββSafari, but you can get a screenshot with a little ingenuity. The following method displays a screenshot from ShareViewController.
func captureScreen() -> UIImage { // Get the "screenshot" view. let view = UIScreen.mainScreen().snapshotViewAfterScreenUpdates(false) // Add the screenshot view as a subview of the ShareViewController view. self.view.addSubview(view); // Now screenshot *this* view. UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, 0); self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) let image: UIImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // Finally, remove the subview. view.removeFromSuperview() return image }
source share