iphone - Save UIView with CALayer.mask as UIImage in iOS 6 -


i have following code:

if ([[uiscreen mainscreen] respondstoselector:@selector(scale)]) {     uigraphicsbeginimagecontextwithoptions(mainview.bounds.size, no, [uiscreen mainscreen].scale); } else {     uigraphicsbeginimagecontext(mainview.bounds.size); }  [mainview.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *saveimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); 

in mainview, there masked subview not appear in saveimage when using method. however, understand there used uigetscreenimage method pre ios 4 did capture such activity. question is, best way capture calayer activities in ios 6? uigetscreenimage still private?

i think there similar question week ago: mask not work when capturing uiview uiimage

on ios6 there problem capturing uiview mask applied (btw, in ios 7 has been fixed): capture image mask not applied.

i posted lengthy solution involved applying mask manually captured image. it's not difficult , made demo project of this. can download here:

https://bitbucket.org/reydan/so_imagemask

if did not understand problem correctly, please tell me can remove answer.


Comments