iphone - UIImage Saving issue in iOS7 : Blending issue -
here screenshot simulator , saved image:

code :
uigraphicsbeginimagecontext(self.view.bounds.size); [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *screenshotimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); //guru - simulator nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *filepath = [[paths objectatindex:0] stringbyappendingpathcomponent:@"image.png"]; [uiimagepngrepresentation(screenshotimage) writetofile:filepath atomically:yes]; //end guru uiimagewritetosavedphotosalbum(screenshotimage, nil, nil, nil); how can fix problem ? works when build xcode4_ios6, not xcode5_ios7.
you can fix in way:
if([self is_ios_7]) { uigraphicsbeginimagecontextwithoptions(self.view.bounds.size, true, [[uiscreen mainscreen] scale]); } else { uigraphicsbeginimagecontext(self.view.bounds.size); } [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *screenshotimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uiimagewritetosavedphotosalbum(screenshotimage, nil, nil, nil); ios7 check:
-(bool)is_ios_7 { nsstring *currosversion = [[uidevice currentdevice] systemversion]; float sysver = [currosversion floatvalue] ; if(sysver >=7.0f) return true; return false; }
Comments
Post a Comment