Cy.
Cy.

Reputation: 2145

Is there any other way than @2x to let iOS know that the graphic is Retina Display ready?

I have a web service producing two versions of graphics; one for Normal Display and another for Retina Display.

Unfortunately I can't add the @2x to the filename since I don't have access to that code.

Is there any way to let the iPhone know that what's loading from the web is a @2x graphic?

Upvotes: 2

Views: 649

Answers (1)

Marin Todorov
Marin Todorov

Reputation: 6397

Yes there is ... when you load an image resource into an UIImage you can set the scale of that image yourself, ie. tell the iOS whether your image is @2x or not.

This is the code to load the @2x images (in the example from a file, but you can put whatever you want):

[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:2.0 orientation:UIImageOrientationUp];

This is the code to load low res images:

[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:1.0 orientation:UIImageOrientationUp];

Cheers, Marin

Upvotes: 10

Related Questions