The viewcontroller i am taking a screenshot from is set to "over current context" therefore showing an image and info in the view controller under it.
When i however take a screenshot programatically the screen turns black where it is supposed to be transparent therefore showing the viewcontroller under it.
how can this be solved?
let bounds = UIScreen.main.bounds
UIGraphicsBeginImageContextWithOptions(bounds.size, true, 0.0)
self.view.drawHierarchy(in: bounds, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
My code (Currently returning a black screen where id like it to be transparent showing Viewcontroller under)