http://martiancraft.com/blog/2014/09/vector-images-xcode6/
I have supported vector pdfs through out the project by adding pdfs in xcassets like this:
So when we build our project, Xcode convert pdf into #1x, #2x, and #3x PNG files. And when we run the application, iOS automatically pick the appropriate #1x, #2x, or #3x image that Xcode generated based on the device requirements.
Issue:
In one screen, our icons are dynaminc. That means we get pdf images through API. I am not sure how xcode can convert these pdfs at run time.
Please help!
There is a library called UIImage-PDF which you can use to load your PDFs into a UIImage at runtime. https://github.com/mindbrix/UIImage-PDF
Related
One of our team member is urging to use SVGs using github.com/pocketsvg/PocketSVG, instead of regular assets #1x #2x #3x. We have over a hundred image sets.
I have 2 questions:
1) 100s of SVG data rendered using PocketSVG or even another library, is that gonna be a performance kill?
2) Using SVGs over regular assets, going to make any different visually, though our designer have these all images extracted properly using vectors.
Thanks in advance.
Answer for first Question : Yes, Whenever trying to show an image on the screen, it will process your SVG file and create a new image assets. May be the library can cache the image to avoid second time processing.
You no need to use PocketSVG if you have all SVG images on your Asset Catalog. Because Xcode Asset catalog itself able to handle the SVG images.
Xcode will create #1x #2x #3x images from SVG file at the time of compilation.
Answer for second Question : SVG is a vector image. You can extract good quality image from svg. You will not get any different by using #1x #2x #3x images or SVG image.
The advantage of using SVG is no need to create one more asset #4x if Apple introduced another different screen resolution devices. Just recompile the code Xcode will create on behalf of you
Refer the link : How to use vector in Xcode
I am trying to use PDF Image in my Asset Catalogs files to automatically generate png files. This feature as been presented in WWDC 2014, video 411 (What's new in Interface Builder)
On iOS XCode is supposed to render the PDF to #1x, #2x, #3x PNG at the build time.
It checked at my generated archives using cartool (cannot post the link as I lack reputation on SO) and it seems only the #1x and #2x resolutions are generated.
I looked a bit around the internet and found this post and this one. The later provides a sample project, which I tried. It also only generated those 2 resolutions.
Did anyone tried this and lucky generated #3x images?
Regards
Nicolas
Found a fork that someone made. Seems to have worked for me to also get the #3x PNG files. Hope this helps!
https://github.com/G-P-S/cartool
I love using the new PDF vector images in Xcode 6 Asset Catalogs a.k.a xcassets. I know that on iOS, these PDF's are rendered down at build time to #1x, #2x etc. PNG's and then embedded into the runtime asset catalog.
However I need at least two different sets of sizes: standard and double-sized. Effectively, I would need #1x, #2x and #3x for the standard icons and #2x, #4x and #6x for the double-sized icons.
Question: how can I get these non-standard sizes from the single PDF? I don't necessarily need a fully dynamic sizing, just two sets of sizes. If Xcode 6 doesn't support this, are there any easy tools that will simply double the size of the PDF?
We switched our XCode project over to use the Asset Catalog during a redesign. We needed several large background images, which we included in the asset catalog. The images were originally JPEGs that we renamed to PNGs to save space. The size of the images on disk is 19.1MB, but when we archive the app the Assets.car file that is generated is 6 times larger than that. I have tried using PNGs and compressing them, but the size is still huge. I'm not sure what else I can do.
It turns out that any image no matter what the original format is converted into a png during the archiving process. I moved the images to the old format of using images and the app size returned to normal.
Xcode "compresses" PNG files by default when building project. So if your JPEGs are renamed as .png, they will be converted to real PNGs then compressed.
This behaviour can be disabled. Just change Compress PNG Files option to NO in project build settings.
This is related to Default-Portrait.png for iPad: any way to make the file size smaller?
Is there any way to specify a more efficient file format (like JPEG) for Default-Landscape.png
and Default-Portrait.png?
Yes it's possible to use jpg files as launch images. Just add "Launch image" key with the base filename (e.g. LaunchImage.jpg") to the Info.plist. Then add files to your project such as
LaunchImage.jpg
LaunchImage#2x.jpg
LaunchImage-568h#2x.jpg
and Xcode will pick them up.
However through personal experience I've discovered if you're supporting the larger iPhone 5 screen the App Store expects PNG format and uses the presence of PNG to determine iPhone 5 support and display of iPhone 5 size thumbnails on the store. Using JPG images will not show the app as iPhone 5 optimized in the app store (even though it will work fine on the device) so it is best to stick with PNG.
There is no way to use an image other than a png.
All launch images must be PNG files and must reside in the top level of your app’s bundle directory. Section: App Launch (Default) Images
Update: JPEG images to work and Apple's documentation no longer specifies that the images must be PNG files.
If you use xcassets, then since Xcode 6 you can use JPGs. However Xcode will still not let you drop JPGs into the LaunchImage folder. But you can do it in Finder. Simply drop your PNGs into that folder with Finder and then edit the JSON file changing all .png extensions to .jpg.
I haven't submitted an app to the store using this yet, but it works in the iPhone simulator at least.
Update: Doesn’t work on the device. I’ll leave this answer here anyway so people know that this technique was at least tried so the effort won’t be repeated.