Power of screenshot!!
Simply, make a screenshot of your app and render the frame f your captured image, adding the UI components that you want.
Very easy.
How to?
Step 1, create a UIImage+Screen category and add these lines in your .h:
[code lang=”java” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]#import <uikit /UIKit.h>
CGImageRef UIGetScreenImage();
@interface UIImage (Screen)
+ (UIImage *)imageWithScreenContentsCroppingRect:(CGRect)rect;
@end[/code]
and in your .m:
[code lang=”java” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]#import "UIImage+Screen.h"
@implementation UIImage (Screen)
+ (UIImage *)imageWithScreenContentsCroppingRect:(CGRect)rect {
CGImageRef cgScreen = UIGetScreenImage();
if (cgScreen) {
UIImage *result = [UIImage imageWithCGImage:cgScreen];
cgScreen = CGImageCreateWithImageInRect(result.CGImage, rect);
result = [UIImage imageWithCGImage:cgScreen scale:result.scale orientation:result.imageOrientation];
CGImageRelease(cgScreen);
return result;
}
return nil;
}
@end[/code]
Now, when you want call imageWithScreenContentsCroppingRect method:
[code lang=”java” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]- (void) ShowWaiting:(BOOL)val
{
[[UIApplication sharedApplication] setStatusBarHidden:val];
if ( !val ) return;
//
// _Image is an UIImageView created before…
//
_Image.frame = CGRectMake(0, -20, 320, 20);
_Image.contentMode = UIViewContentModeTopLeft;
_Image.image = [UIImage imageWithScreenContentsCroppingRect:CGRectMake(0, 0, 320, 20)];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(80, 0, 320-80, 20)];
v.backgroundColor = [UIColor blackColor];
UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 320-90, 20)];
l.textColor = [UIColor lightGrayColor];
l.backgroundColor = [UIColor clearColor];
l.font = [UIFont boldSystemFontOfSize:14];
l.text = @"Loading data…";
[v addSubview:l];
[_Image addSubview:v];
[l release];
[v release];
}[/code]
Probably use of UIGetScreenImage() is illegal for App Store rejection!
enjoy editing!
Rif: albertopasca.it