Recently did the project encountered the request to intercept the image length beyond the phone screen, you can slide the long picture screenshot, here is a simple solution to the idea, the following demo.
, when we want to truncate the full screen, record the frame and offset of the slide view, then set the slide view offset to 0,frame to slide the view
Contentsize, and then generate a picture to save, the code is implemented as follows:
The following method, the first parameter represents the size of the area. The second parameter indicates whether it is non-transparent. If you need to display a translucent effect, you need to pass no, otherwise pass yes. The third parameter is the screen density, which adjusts the sharpness. uigraphicsbeginimagecontextwithoptions (Scroll.contentsize, YES, [UIScreen mainscreen].scale); Cgpoint savedcontentoffset = Scroll.contentoffset; CGRect savedframe = scroll.frame; Scroll.contentoffset = Cgpointzero; Scroll.frame = CGRectMake (0, 0, scroll.contentSize.width, scroll.contentSize.height); [Scroll.layer Renderincontext:uigraphicsgetcurrentcontext ()]; Image = Uigraphicsgetimagefromcurrentimagecontext (); Scroll.contentoffset = Savedcontentoffset; Scroll.frame = Savedframe; Uigraphicsendimagecontext ();
Demo:https://github.com/zk1947/capturescreen
iOS Development Slide Long screenshot full Screen app