IPhone DevelopmentApplication in progressScreenshot ProgramCase implementation is the content to be introduced in this article, mainly through codeScreenshot Program, The specific implementation process, let's look at the detailed code.
- // Obtain the screen image
- -(UIImage *) imageFromView: (UIView *) theView
- {
- UIGraphicsBeginImageContext (theView. frame. size );
- CGContextRef context = UIGraphicsGetCurrentContext ();
- [TheView. layer renderInContext: context];
- UIImage * theImage = UIGraphicsGetImageFromCurrentImageContext ();
- UIGraphicsEndImageContext ();
- Return theImage;
- }
-
- // Obtain the screen image within a certain range
- -(UIImage *) imageFromView: (UIView *) theView atFrame :( CGRect) r
- {
- UIGraphicsBeginImageContext (theView. frame. size );
- CGContextRef context = UIGraphicsGetCurrentContext ();
- CGContextSaveGState (context );
- UIRectClip (r );
- [TheView. layer renderInContext: context];
- UIImage * theImage = UIGraphicsGetImageFromCurrentImageContext ();
- UIGraphicsEndImageContext ();
- Return theImage; // [self getImageAreaFromImage: theImage atFrame: r];
- }
Summary:IPhone DevelopmentApplication in progressScreenshot ProgramThe implementation of the case is complete. I hope this article will help you!