#pragma mark-screenshot-(UIImage *) Convertviewtoimage: (UIView *) view{ //https://github.com/alskipp/asscreenrecorder Screen code //The second parameter indicates whether it is non-transparent. If you need to display a translucent effect, pass no, otherwise yes. The third parameter is the screen density of uigraphicsbeginimagecontextwithoptions (View.bounds.size,yes,[uiscreen mainscreen].scale); [View.layer Renderincontext:uigraphicsgetcurrentcontext ()]; UIImage *image = Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); return image; -(UIImage *) Snapshotview: (UIView *) view{ uigraphicsbeginimagecontextwithoptions (view.bounds.size,yes,[ UIScreen Mainscreen].scale); [View DrawViewHierarchyInRect:view.bounds Afterscreenupdates:no]; UIImage *image = Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); return image;
IOS View snapshot, view screenshot