Posted By

vaishnavi on 12/09/10


Tagged

UIView UIImage


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

vaishnavi
sag333ar
terababy
Tintenklecks
cnathan


Take any view and make a UIImage out of it.


 / Published in: Objective C
 

Any view and it's subviews will be "flattened" into a UIImage that you can display or save to disk.

  1. - (UIImage*)imageFromView{
  2.  
  3. UIImage *image;
  4.  
  5. UIGraphicsBeginImageContext(self.view.bounds.size);
  6. [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
  7. image = UIGraphicsGetImageFromCurrentImageContext();
  8. UIGraphicsEndImageContext();
  9.  
  10. return image;
  11.  
  12. }

Report this snippet  

You need to login to post a comment.