Reputation: 4042
There are iPhone 6
and iPhone 6 plus
device available from apple.
@2x
and @3x
. When I load image using UIImage imageNamed:
. @3x
ad the end of file? My naming convention is pic.png
, [email protected]
, [email protected]
. iPhone 6
and then [UIImage imageNamed:@"[email protected]"]
or just [UIImage imageNamed:@"pic"]
and the device will automatically use the right image for the right device?Upvotes: 5
Views: 4106
Reputation: 11217
Sol: [UIImage imageNamed:@"pic"]
is enough instead of [UIImage imageNamed:@"pic.png"]
.
Reason:
[email protected]
& [email protected]
once you added into you project. [email protected]
or [email protected]
image means device will load pic.png automatically. [UIImage imageNamed:@"pic"]
in your project.Upvotes: 11
Reputation: 2585
TLDR: be sure to include @2x images if you are supporting iOS 6/7, or specify "*@3x" in imageNamed.
If you support older version of iOS (6/7), you need to do 1 of 2 things.
First option: include all versions of an image (normal, 2x, 3x). Preferred.
Second Option: if you only include a @3x image, [UIImage imageNamed"pic"]
will work great on iOS 8 (downscaling the 3x image to 2x or 1x size as needed), however, it fails on iOS 7 since iOS 7 wasn't ever aware of @3x. You should use [UIImage imageNamed"pic@3x"]
Upvotes: 0
Reputation: 19005
[UIImage imageNamed:@"pic"]
is enough.
Suffixes (@2x for iPhone 4 to 6 and @3x for iPhone 6 plus) are added automatically if image with this suffix is found.
Upvotes: 2