I have a UIScrollView
decendent that implements a takeScreenshot method that looks like this:
-(void)takeScreenshot {
CGRect contextRect =
I have found below code and its working for me. try this ..
extension UIView {
func capture() -> UIImage {
UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.main.scale)
drawHierarchy(in: self.bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}}