문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top