ios - No Background when Rendering an UIView to a PDF -


in ipad app use following method render uiview pdf.

+ (nsdata*)createpdffromuiview:(uiview*)aview {     nsmutabledata *pdfdata = [nsmutabledata data];      uigraphicsbeginpdfcontexttodata(pdfdata, aview.bounds, nil);     uigraphicsbeginpdfpage();     cgcontextref pdfcontext = uigraphicsgetcurrentcontext();      [aview.layer renderincontext:pdfcontext];      uigraphicsendpdfcontext();      return pdfdata; } 

this works quite fine. problem rendered correctly (all subviews) views background white. have change if want view's background rendered correctly?

if view has valid bg, rendered pdf:

@implementation viewcontroller  - (void)viewdidload {     [super viewdidload];      //bg     self.view.backgroundcolor = [uicolor redcolor];      //make pdf     nsdata *pdf = [viewcontroller createpdffromuiview:self.view];     [pdf writetofile:@"/users/dominik/t.pdf" atomically:no];  }  + (nsdata*)createpdffromuiview:(uiview*)aview {         //question source code (see above) } @end 

so: set backgroundcolor


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -