Pregunta

I am developing a game for the app store and have been using Sprite Kit. In Sprite Kit to have the game work on both the iPhone and the iPad I set the SKScene's scaleMode=SKSceneScaleModeAspectFill and made the screen proportions so it would fit the iPhone 4&5 screens as well as the iPad and this has worked well. Now I am building the menus for the app, but I am not using Sprite Kit for this. Instead I am using Collection Views, Buttons, images, etc. I am not seeing a similar property to scale the view to a certain size depending on what device I am on. Since I am using images for all of my buttons, ideally just proportionately scaling everything would be the simplest way to achieve what I am looking for. Am I missing something as far as how best to proceed with this? Thanks in advance.

¿Fue útil?

Solución

You are describing Auto Layout. It is the feature specifically designed for this very purpose, i.e. to change sizes and distances of interface objects in response to the fact that the screen is a different size.

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html

However, for a size difference as great as the iPad vs. the iPhone, if you have a universal app, it sometimes makes sense to design two different interfaces. It is easy to set up the Info.plist or your initial code to load the correct interface depending on which device type this turns out to be at runtime. In fact, if you start by making a Universal app, the project will simply come with two storyboards, one for iPhone and one for iPad, which are loaded automatically.

Another option (which didn't occur to me at first because I don't write these kinds of game) is to scale a superview by applying a view transform (i.e. set its transform to a scale transform). That scales the view's coordinate system, so all its subviews will change to match, just like a drawing.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top