The basic principle is to describe the layer of the uiview to the graphic context. UiviewCodeAs follows:
1 uiview global photo taking
-(Uiimage *) screenimage :( uiview *) view {uiimage * screenimage; uigraphicsbeginimagecontext (view. frame. size); [view. layer renderincontext: uigraphicsgetcurrentcontext ()]; screenimage = uigraphicsgetimagefromcurrentimagecontext (); uigraphicsendimagecontext (); Return screenimage ;}
2 uiview Local Image taking
-(Uiimage *) screenimage :( uiview *) view rect :( cgrect) rect {cgpoint Pt = rect. origin; uiimage * screenimage; uigraphicsbeginimagecontext (rect. size); cgcontextref context = uigraphicsgetcurrentcontext (); cgcontextconcatctm (context, cgaffinetransformmaketranslation (-(INT) pt. x,-(INT) pt. y); [view. layer renderincontext: Context]; screenimage = uigraphicsgetimagefromcurrentimagecontext (); uigraphicsendimagecontext (); Return screenimage ;}