Xcode4.2,SDK is 5.0
QuartzCore.framework has been added.
#import <QuartzCore/QuartzCore.h>
@property (retain, nonatomic) IBOutlet UIImageView *imageView;
-(UIImage*)getShot
{
CGSize imageSize = CGSizeMake(320, 460);
UIGraphicsBeginImageContext(imageSize);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
it works fine in iOS5,but not in iOS4.
Whether I use the
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0)
or
UIGraphicsBeginImageContext(imageSize)
it doesn’t help.
1 Answer