ios - renderInContext not support mask? -


i have camera app load photo device mask. ok. when try use renderincontext save view image, see image without mask.

uigraphicsbeginimagecontext(contentview.bounds.size); cgcontextref context = uigraphicsgetcurrentcontext(); [contentview.layer renderincontext:context]; uiimage *outimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uiimagewritetosavedphotosalbum(outimage, self, @selector(image: didfinishsavingwitherror: contextinfo:), context); 

i have read paper apple renderincontext don't support mask , composition. i've made search on internet information uiview needed draw context first , use renderincontext save image.

now question method job? drawrect, drawinrect, drawlayer, drawincontent, or other method. can give me hint. lots.

i started here: http://chinkisingh.com/2013/03/03/draw-on-iphoneipad-screen-using-bezier-paths-core-graphics-ios-app-development/

i have uibezierpath , wanted apply gradient , apply existing image, see if following code helps

    cgrect r = cgrectmake(0, 0, heart_size, heart_size);     uibezierpath *heart = [bezier heartshape:r]; //this in case      cgcolorspaceref colorspace = cgcolorspacecreatedevicergb();     uicolor *darkpink = [uicolor colorwithhue:0.915 saturation:1.000 brightness:0.941 alpha:1.000];     uicolor *lightpink = [uicolor colorwithhue:0.917 saturation:0.647 brightness:1.000 alpha:1.000];      nsarray *gradientcolors = [nsarray arraywithobjects:                                (id)darkpink.cgcolor,                                (id)lightpink.cgcolor,                                (id)darkpink.cgcolor, nil];     cgfloat gradientlocations[] = {0, 0.5, 1};     cggradientref gradient = cggradientcreatewithcolors(colorspace, (__bridge cfarrayref)gradientcolors, gradientlocations);      cgcolorspacerelease(colorspace);       uigraphicsbeginimagecontext(r.size);     heart.linecapstyle = kcglinecapround;     heart.linewidth = 10.0f;     [[uicolor blackcolor] setstroke];     [[uicolor redcolor] setfill];     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsavegstate(context);      [heart stroke]; //removed black stroke around     [heart fill];     cgcontextaddpath(context, heart.cgpath);     cgcontextclip(context);     cgcontextdrawlineargradient(context, gradient, cgpointmake(10, 10), cgpointmake(210, 210), kcggradientdrawsafterendlocation); //check gradient drawn in right place      cggradientrelease(gradient);     uiimage *therightimage = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext(); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -