As you probably notices, simple screen drawing is useless if it comes to OpenGL view. So is it possible to generate UIImage from such? Of course, lets suppose your custom drawing class extends UIView, then just add:

This code works in XCode 9 and Swift 3.x.

This can seem trivial, but I saw lot of people complaining about not working tint color when using UIImage. Here is the proper way:

UIImageView *imageView = [[UIImageView alloc] init];
UIImage *image = [UIImage imageNamed:@"my_image"];
imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[imageView setTintColor:[UIColor redColor]];

The point is – “imageWithRenderingMode” method just returns new image with rendering mode set, it does not changes anything in image object itself.