Take any view and make a UIImage out of it.


/ Published in: Objective C
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.