Swift: how exactly do assets work for different sized devices?

skyguy

So I have a game that I made in Swift and I built it and all of its assets for the iPhone 5s. So naturally when built for a 4s or an iPad the game looks distorted and the image views are in the wrong place.

How do I get around this so that the game can work on both the 4/4s and 5/5s? Where do I put the smaller images? I see the 1x and 2x but what exactly does this mean?

Oscar Swanros

Every iPhone since the iPhone 4 in 2010 has a Retina Display. Now we have iPads with Retina Display, too.

You can have an asset named "image1.png" and a higher resolution version of the same asset named "[email protected]". Adding the "@2x" to the end of the file name, iOS knows which asset to use based on the current device's display.

Regarding your "So naturally when built for a 4s or an iPad the game looks distorted and the image views are in the wrong place" comment: what you want to pay attention to here is the actual screen size of the devise you're designing for.

The iPhone 4/4S has a screen resolution of 640 x 960 pixels, while the iPhone 5/5c/5s has a screen resolution of 640 x 1136. The iPad's screen resolution for Retina Display models is 2048 x 1536.

So, I think that your problem is not about creating the assets, but about how you arrange them on screen.

I'd recommend taking a look into an AutoLayout tutorial.

Hope I've shed some light on your problem.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How does keytab work exactly?

来自分类Dev

How to get list of names of available bluetooth devices in ios swift?

来自分类Dev

How to show id with exactly three different cases in M:m table SQL

来自分类Dev

How exactly does queryForMap() and queryForList() methods provided by the Spring JdbcTemplate work internally?

来自分类Dev

How to do something different for every part of a code?

来自分类Dev

How do memory booster/optimizer work?

来自分类Dev

What are Windows Kits and how do they work?

来自分类Dev

how do I print an integer in Swift

来自分类Dev

SpriteKit how to create and transition to different scenes (Swift language)

来自分类Dev

What exactly does _malloc do in assembly?

来自分类Dev

How to get Storyboard to support dynamically sized cells in UICollectionView?

来自分类Dev

How do paths work in a Java deployed REST web service?

来自分类Dev

How do i configure Activiti 5.14 to work as per 'Activiti In Action'?

来自分类Dev

How do I get my nested if statement to work in jQuery

来自分类Dev

How and when exactly does a finally block execute?

来自分类Dev

How do I report error when setting a swift property?

来自分类Dev

Swift: How do I return a value within an asynchronous urlsession function?

来自分类Dev

Swift: How do I get access to the navigationController in AppDelegate

来自分类Dev

How do I implement AVAssetImageGenerator.copyCGImageAtTime in swift

来自分类Dev

How do I get a value from an associative array using Swift

来自分类Dev

How do I reload an Angular 6 component when a different component (that is not the parent/child) says to do so

来自分类Dev

Why do two web pages have different localStorage? How can I fix this?

来自分类Dev

How do you present a different PKI client certificate to a server once you have already presented one, in Firefox?

来自分类Dev

Why google Account login is required for GCM to work for devices below 4.0.4 OS?

来自分类Dev

How do i get multiple independant document.onkeydown events to work?

来自分类Dev

How do I get an ng-show to work inside an ng-repeat on a variable declared outside that scope?

来自分类Dev

How do I get the each method to work with multiple inputs using MagicSuggest?

来自分类Dev

Different let in for lines in do block

来自分类Dev

ColorSense-For-XCode plugin not work in swift code

Related 相关文章

  1. 1

    How does keytab work exactly?

  2. 2

    How to get list of names of available bluetooth devices in ios swift?

  3. 3

    How to show id with exactly three different cases in M:m table SQL

  4. 4

    How exactly does queryForMap() and queryForList() methods provided by the Spring JdbcTemplate work internally?

  5. 5

    How to do something different for every part of a code?

  6. 6

    How do memory booster/optimizer work?

  7. 7

    What are Windows Kits and how do they work?

  8. 8

    how do I print an integer in Swift

  9. 9

    SpriteKit how to create and transition to different scenes (Swift language)

  10. 10

    What exactly does _malloc do in assembly?

  11. 11

    How to get Storyboard to support dynamically sized cells in UICollectionView?

  12. 12

    How do paths work in a Java deployed REST web service?

  13. 13

    How do i configure Activiti 5.14 to work as per 'Activiti In Action'?

  14. 14

    How do I get my nested if statement to work in jQuery

  15. 15

    How and when exactly does a finally block execute?

  16. 16

    How do I report error when setting a swift property?

  17. 17

    Swift: How do I return a value within an asynchronous urlsession function?

  18. 18

    Swift: How do I get access to the navigationController in AppDelegate

  19. 19

    How do I implement AVAssetImageGenerator.copyCGImageAtTime in swift

  20. 20

    How do I get a value from an associative array using Swift

  21. 21

    How do I reload an Angular 6 component when a different component (that is not the parent/child) says to do so

  22. 22

    Why do two web pages have different localStorage? How can I fix this?

  23. 23

    How do you present a different PKI client certificate to a server once you have already presented one, in Firefox?

  24. 24

    Why google Account login is required for GCM to work for devices below 4.0.4 OS?

  25. 25

    How do i get multiple independant document.onkeydown events to work?

  26. 26

    How do I get an ng-show to work inside an ng-repeat on a variable declared outside that scope?

  27. 27

    How do I get the each method to work with multiple inputs using MagicSuggest?

  28. 28

    Different let in for lines in do block

  29. 29

    ColorSense-For-XCode plugin not work in swift code

热门标签

归档