iOS Dev Nugget 62 Using PDF Instead of PNG Files for Resizable Assets


Need to run a code review on your codebase? Hire me

For certain apps such as those that let you pick an app-provided image and then let the user resize and rotate them, it's helpful to keep the asset as a PDF instead of rasterized PNGs. Since the user can resize them, sometimes you will want to have different resolutions of the same image. Doing this with rasterized PNGs is both time-consuming and takes up more space. If you save them as vectors in PDF files, you can convert them into UIImage instances at run time, with the appropriate size. Nigel Timothy Barber's UIImage-PDF lets you convert – at runtime – PDFs to UIImages:

UIImage* img = [UIImage  imageWithPDFNamed:@"some-pdf.pdf" fitSize:CGSizeMake(600, 600)];
//Do something with img

Check it out.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues