I use the well-known template to create a UIImage from a UIView :
+ (UIImage *) imageWithView:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; }
Now my problem is that I have a very complex view with a lot of subqueries on it, so this conversion process takes about 3 + (!!!) seconds.
I tried using it in another thread that runs in the background, and it really improved performance.
The only problem is that, as I can remember, it is not allowed to create things related to the user interface out of the main thread.
Am I mistaken and is this beautiful? Or - if I'm right - what can be done to increase productivity? is there any other method that i can use in another thread but doing the same job?
Thanks a lot!
source share