guys, this is my code:
- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
//background
CGContextSetFillColorWithColor(ctx, [[
For Swift 3
func getImageFromContext() -> UIImage{
UIGraphicsBeginImageContextWithOptions(self.frame.size, false, UIScreen.main.scale)
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
self.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}