Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. specifying a CGRect for image capture (iPhone)
  2. CGRect screenRect = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height);
  3. UIGraphicsBeginImageContext(screenRect.size);
  4.  
  5. CGContextRef ctx = UIGraphicsGetCurrentContext();
  6. [[UIColor blackColor] set];
  7. CGContextFillRect(ctx, screenRect);
  8.  
  9. [self.view.layer renderInContext:ctx];
  10.  
  11. UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
  12. UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
  13. UIGraphicsEndImageContext();
  14.        
  15. CGRect screenRect;
  16. switch (runningOniPad) {
  17.     case 0: // running on iPhone..
  18.         screenRect = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height);
  19.         break;
  20.  
  21.     default: // yes, running on iPad..
  22.         screenRect = CGRectMake(56, 478, 662, 262);
  23.  
  24.         break;
  25. }