Reputation: 427
I'm using asset catalog to manage all my app's images, and I load those images "normally" [UIImage imageNamed:@"my-image"];
What I want to do is load the non-retina version of the image from the asset catalog, on a retina display, but I can't figure out how/know if it's even possible. Any insights would be helpful.
Thanks in advance
Upvotes: 1
Views: 792
Reputation: 427
I have found a solution, but only available in iOS 8:
+ (UIImage *)imageNamed:(NSString *)name
inBundle:(NSBundle *)bundle
compatibleWithTraitCollection:(UITraitCollection *)traitCollection
where
(UITraitCollection *)traitCollectionWithDisplayScale:(CGFloat)scale
So you can use:
// pass nil to inBundle to use the main bundle
[UIImage imageNamed:@"my-image"
inBundle:nil
compatibleWithTraitCollection:[UITraitCollection traitCollectionWithDisplayScale:1.0]];
Upvotes: 2