- (UIImage *)captureScreenshot {
UIGraphicsBeginImageContextWithOptions(self.bounds.size,NO, [UIScreenmainScreen].scale);
if ([selfrespondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
[selfdrawViewHierarchyInRect:self.boundsafterScreenUpdates:NO];
}
else {
[self.layerrenderInContext:UIGraphicsGetCurrentContext()];
}
UIImage *screenshot =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenshot;
}