How to deal with retina assets (titanium) - ios7

I have 2 sets of files:
1) Non retina images and retina images.
I am currently using the non retina images in my app. How and when do I use the retina images.
Thanks

add a retina image with "#2x" to the filename and Titanium will automatically display that if the OS is retina, e.g. if your image is "example.png", add an image called "example#2x.png".
Here's a good explanation: http://fokkezb.nl/2013/09/17/smarter-image-paths/
I can't find the link to the Titanium documentation unfortunately, though I'm sure it's explained there somewhere...
EDIT: Thanks to #Dragon for the docs link

Related

iOS Universal Image Assets

For a new project my client wants to cover all iPhone and iPad sizes. For icons and sprites I'm not really gonna change the shapes of the images, but I'm in a bind with assets for my background images.
Looking at http://iosres.com I was wondering if there is some logic to cover both Landscape and Portrait 3:4 and 9:16 in one asset or should I simply make a set of iPhone and iPad and use UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad to figure out what to show before loading my views?
Also I'm wondering what's most effective for all the different device sizes. I know from experience that an iPad 3 wouldn't like to have a background image loaded on 4k resolution and that you want to avoid pixel differences so it won't trigger scaling in UIImageViews. Will iOS automatically figure out that the iPad 3 will use like the #1x variations, whereas the iPad Pro will load the #3x versions?
Yes iOS will automatically figure out which image to load at runtime and load #1x #2x or #3x depending upon the type of device. You don't need to do anything like UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad for each image.
Edit:
You can also add ~ipad suffix in image names so iOS will pick the appropriate background image for iPhones and iPads. i.e. image_name#2x~ipad.png and image_name#2x.png.

iOS UI Custom button images

I'm developing a iOS app that is using custom UIButtons with round shape. I wanted to add Image to these buttons and would like to know if I use IB to select an image from my project, do I have to also worry about 2x retina images for retina display?. What should be the image size for both non-retina and retina devices (all iPhones (including iphone 5) and iPad including mini) when I embedded them from IB?
Is there a best resource available on the Internet to get these pngs files for buttons?
Yes you should use all the images. you should just add the images with proper names to the resources folder. And just select the non-retina image rest the compiler will take care of.
http://www.idev101.com/code/User_Interface/sizes.html
The above link will help you with the images sizes
It is easy. Goto interface builder and on the right hand panel you will see this -
All you need to do is first configure your button as custom then include a image file in your project through xcode and then you can select that image in the dropdown in background or image property.
Note that all this is possible to do through code also, its just that IB makes it interactive. Hope this helps.

Retina graphics vs non-retina graphics management

I am about to launch a new app and would lik eto increase quality of the graphics. In my case the graphics is the logo and the custom buttons. I do not know if this impact Core Plot but that is also part of the package.
There is quite a few posts about this but there are still things i do not fully understand.
I am reading this quote from "amattn":
It's trivial:
1.Only include #2x images in your project.
2.Make sure those images have the #2x suffix.
The system will automatically downscale for non-retina devices.
The only exception is if you are doing manual, low level Core Graphics drawing.
You need to adjust the scale if so. 99.9% though, you don't have to worry about this.
From this post: Automatic resizing for 'non-retina' image versions
My question in regards to this is:
1. Should i do the testing on retina simulator only, as if i place a #2 grapic on
non-retina it will be too big? ...or is there an other way of doing it?
2. Should i always use a ImageView or is it OK to drag the image on the screen,
this is the logo i am talking about?
3. What about custom made buttons with images, how should i do with those?
4. What is the normal process to manage the different screen sizes, do people
add images for all displays or using this type of process?
Should i do the testing on retina simulator only, as if i place a #2 grapic on non-retina it will be too big? ...or is there an other
way of doing it?
It doesn't really matter which simulator you test on because as long as your non-retina and retina graphics are named correctly (image and image#2x) the correct image will be displayed automatically.
Should i always use a ImageView or is it OK to drag the image on the screen, this is the logo i am talking about?
When you drag and image from the project directly onto a view in interface builder you don't really see it happen but it has automatically created and image view which is containing the image your dropped in.
What about custom made buttons with images, how should i do with those?
[myButton setImage:[UIImage imageNamed:#"myFileName"]];
As shown in the above code you should always use the non-retina fle name when you reference the image a UI element should use. That was if iOS detects the device is retina it can automatically use the #2x version in its place.
What is the normal process to manage the different screen sizes, do people add images for all displays or using this type of process?
Yes, including multiple image resolutions common practice and is required for iPhone apps (not sure about iPad) to include both retina and non-retina images. But regardless of the requirements, you should definitely support both device resolutions to keep your customers happy!

what is image size(resolution) for iPad 3 application development?

As we know iPad 3 have 2048×1536 resolution.
for iPhone 4 with retina display we put big image with name #2X and one normal image in our bundle.
so for iPad 3 application development we also need to put two images one is normal size and other with big size with #2X name..?
Any one know please reply.
With the iPad 3, you also simply need to name your retina images foo#2x.png. It needs to be exactly two times the resolution of the corresponding foo.png. So, say foo.png is 10x10, then your foo#2x.png needs to be 20x20.
You can also make version specifically for iPhone/iPod or iPad and iOS will automatically chose the correct version. For this, you can use the ~iphone and ~ipad modifiers:
foo.png for all devices with non-retina display
foo~iphone.png specifically for iPhone/iPod non-retina
foo~ipad.png specifically for iPad non-retina
foo#2x.png for all devices with retina display
foo#2x~iphone.png specifically for iPhone/iPad retina
foo#2x~ipad.png specifically for iPad retina
You can mix them in any combination, as long as there's always a version for all your supported devices (if you're doing an iPad-only app there's no need to provide images for iPhone, of course). So it's OK to provide for example foo~iphone.png, foo~ipad.png and then foo#2x.png.
I think it would be "image~ipad" & "image#2x~ipad" for iPad with Retina Display if you are writing a Universal app (since "image" & "image#2x" are for iPhone/iPod images).
Otherwise I guess "image" & "image#2x" is OK.
Refer to How to support both iPad and iPhone retina graphics in universal apps .

Automatic inclusion of #2x images (retina support)

Can any one tell me code of auto including #2x images if device is switched to iphone 4.
I have searched very far on it, but nothing fruitful is found yet.
I have already included #2x images in my resource file. I want code to write so that images resize and reposition them selves when application is running on iphone 4.
What do you mean by "auto-including" ?
If you have fooBar.png and fooBar#2x.png in your project resource, then when you do :
UIImage * fooBarImg = [UIImage imageNamed:#"fooBar.png"];
It will automatically load fooBar.png if your screen scale is 1.0 (iPhone3G/3GS) or fooBar#2x.png if your screen scale is 2.0 (retina, iPhone 4).
cf UIImage#imageNamed
Just include the #2x with the normal image in your project, the os will get the #2x if needed.
When you refer to an image always refer to the non-#2x image and iOS will get the #2x image on iphone 4 (or ipod) if you take it in your project and add to the target of course.