I've created an imageset in Assets.xcassets
named Wallpaper.
Since the app I'm working on will only work on iOS 7 or greater it would be useless to embed non-retina images (The iPhone 4, which has retina, is the oldest device to support iOS 7). This results in a blank spot in my imageset.
Now as I'm trying to set a background to my UIView
, I thought that I maybe could use that blank spot as a reference for a fullscreen image for the iPhone 6 (which is now using @2x images).
So I'm looking for a way to make the iPhone 6 use the @1x image, which otherwise wouldn't be used, instead of the @2x image.
Wallpaper imageset Contents.json
{
"images" : [
{
"idiom" : "iphone",
"filename" : "Wallpaper-iPhone@1x.png",
"scale" : "1x"
},
{
"idiom" : "iphone",
"filename" : "Wallpaper-iPhone@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"filename" : "Wallpaper-iPhone@2x-568h.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"idiom" : "iphone",
"filename" : "Wallpaper-iPhone@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
I've already tried the following options to reach Wallpaper-iPhone@1x.png
but none of them seems to work.
UIImage *Wallpaper = [UIImage imageNamed:@"Wallpaper"];
if([UIScreen mainScreen].bounds.size.height == 667) {
// 1. Use the image name, this results in (null).
NSLog(@"%@",[UIImage imageNamed:@"Wallpaper-iPhone@1x.png"]);
// 2. Add the mainBundle to the path, this also results in (null).
NSLog(@"%@",[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Wallpaper-iPhone@1x.png", [[NSBundle mainBundle] resourcePath]]]);
}
[self.view setBackgroundColor:[UIColor colorWithPatternImage:Wallpaper]];
Please note:
- I've already tried to set
"subtype" : "667h"
inContents.json
, but that doesn't seems to work... - I'm aware of the fact that I could use two imagesets to define a iPhone 6 Wallpaper image, but I was wondering if this would work swell.
- The app needs fullscreen so it won't work with splitview. So using the @1x slot won't cause any trouble on any device.