yong ho
yong ho

Reputation: 4042

Do I need to suffix @3x in UIImage imageNamed?

There are iPhone 6 and iPhone 6 plus device available from apple.

Upvotes: 5

Views: 4106

Answers (3)

Rajesh Loganathan
Rajesh Loganathan

Reputation: 11217

Sol: [UIImage imageNamed:@"pic"] is enough instead of [UIImage imageNamed:@"pic.png"].

Reason:

Upvotes: 11

scosman
scosman

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

nicael
nicael

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

Related Questions