Ios_ screenshot and Crop

Source: Internet
Author: User

Usage scenarios:



Code generation snippet in IOS 7

Using context and clipping with the specified area, template code-(void) screenshot{    //Will be view, that is, view of the form's root controller (must not contain status bar, default iOS7 controller is included in the status bar)    Beyondviewcontroller *BEYONDVC = Self.view.window.rootViewController;    The total size of the background picture is    cgsize size = beyondVC.view.frame.size;    Open context, after using the parameters, the original image (yes  0.0 high quality)    uigraphicsbeginimagecontextwithoptions (size, yes, 0.0) is truncated;    The clipping of the key code, the rectangular range to be clipped    cgrect rect = CGRectMake (0, -20, size.width, Size.Height +);    Note: IOS7 after Renderincontext: by drawviewhierarchyinrect:afterscreenupdates: substitution    [Beyondvc.view Drawviewhierarchyinrect:rect  Afterscreenupdates:no];    From the context, remove UIImage    UIImage *snapshot = Uigraphicsgetimagefromcurrentimagecontext ();    Add the captured image to the image array    [_cutimages addobject:snapshot];        Remember, end context (remove stack top)    uigraphicsendimagecontext ();    }


Code Snippets in IOS 6

Using context, template code-(void) screenshot3{    //Will be view, form's root controller view (IOS6, default controller does not contain status bar)    Beyondviewcontroller *BEYONDVC = Self.view.window.rootViewController;    UIView *cutview = Beyondvc.view;    Open context, after using the number of references, the original (yes  0.0 high quality)    uigraphicsbeginimagecontextwithoptions (cutView.frame.size, yes, 0.0);    Render the Cutview layer into context    [Cutview.layer renderincontext:uigraphicsgetcurrentcontext ()];    Remove UIImage    UIImage *image = Uigraphicsgetimagefromcurrentimagecontext ();    Add the captured image to the image array    [_cutimages addobject:image];    Remember, end context    uigraphicsendimagecontext ();}

Ios_ screenshot and Crop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.