Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

ios - What should image sizes be at @1x, @2x and @3x in Xcode?

For example, I have a 100*100 size imageview or button, and I want to set its image or backgroundImage with a local .png file. Based on my understanding, I need to create 3 sets of images, i.e. 100*100 for @1x, 200*200 for @2x, 300*300 for @3x. I am not sure if my understanding is correct or not, can anyone help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to my understanding, if the image size is 100 * 100

@1x -> 100 * 100

@2x -> 200 * 200

@3x -> 300 * 300

enter image description here

There is something to understand. By creating 2x and 3x images, you can't expect exact same layout from each iPhone screen. The layout will be different from screen to screen. 1x, 2x and 3x image sizes dealing with only the pixel density of the screen.

Suppose you have an image which is 320 * 70 and you are creating

@1x -> 320 * 70

@2x -> 640 * 140

@3x -> 960 * 210

This will be your output in different screens. enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...