0
votes

I have icons inside my application for uibutton & on uitable cell. Lets say I have image named "sampleImage.png". Can my app use the image named "[email protected] iphone with retina display automatically provide it is in my app bundle ? If yes how can write code for it because I have code like

cell.imageview.image = [UIImage named:@"sampleImage.png"];

Does it work even if I hardcoded the image name?

Any kind of help is appreciated.Thanks

2
if your application bundle having [email protected] already than it will automatically fetched when application will be run in the ratina display, no need to code for that. But do confirm one thing your image and image@2x name must be same always. - Kuldeep

2 Answers

4
votes

Yes, UIImage will automatically use the @2x version of an image on a retina display.

1
votes

Searching for an answer of your question I came across this: what is the code to detect whether ios app running in iPhone, iPhone Retina display, or iPad?

One of the answers mentions this:

There's often no need to determine directly whether you're on a retina display because UIImage handles that automatically when you use imageNamed and append "@2x" to your high resolution image file names (see Supporting High-Resolution Screens in the Drawing and Printing Guide for iOS).