ioscocoa-touchios8autolayoutios-universal-app

Image sizes with Asset Catalog and Sizing Classes for a iOS 8 Universal app?


My app is currently just for iPad, I think I might be able to just make a smaller version of iPhone, with the 'any' sizing class.

EDIT: I just want to use a universal storyboard if possible.

I think I will just need to select iPad and iPhone in my asset catalog image sets.

I'm hoping I can make proportional constraints, however I'm not sure how to do with without providing constant widths / heights for images.

How do I then work out what images I will need to provide, also whats the best way to provide images?

I've seen you can provide vector images, I believe the documentation said that Xcode would produce the sizes required from them?


Solution

  • 1. Image resources. Essentially, for universal iOS apps (for the iPhone/iPad/AppleWatch UI idioms and various display scale factors), there is an extensible way - Asset Catalogs.

    Once you have configured your assets, you can access your image resources as usual (via UIImage.imageNamed()) and the system will do the rest for you.

    2. Layout constraints/ size classes. When dealing with the layout of your image contents, it's no longer a matter of what images you have - it's a matter of how your app's UI adapts to the idiom of the device it's being run on. At least, you can use aspect ratio layout constraints to make your image views scale proportionally in accordance with the enclosing layout context (device screen size, parent view size, etc.). Also, it's a good practice to utilize size classes.

    P.S. My answer is as vague as the question is. If some of the aforementioned is too broad, please feel free to chat with me on the SO chat. Good luck.