I'm trying to figure out how to make all my elements such as my buttons and labels fit on every iPhone screen size, including the iPhone 6 plus, iPhone 6 and iPhone 5 as well as the other version of the iPhone 5. How can I make this happen? Let's say I have 3 buttons I want centered in the middle of the screen width-wise, one on top of another.
All the screens you listed are of the same type. Your app will look the same on all the screens of the same type, without extra work. However, that's not the end of the story.
There are really only two screen types for iOS. The first one includes all iPhones before and including iPhone 4 and iPads. Another type includes only iPhones 5+. You are supposed to support both types in your application. In fact, Apple will not let you publish an app that doesn't look good on both screen types - hence the requirement to provide screen shots for both 3.5' and 4' screens - which represent each type. In addition, you need to make sure the app runs fine on an iPad, even if you don't plan on supporting iPads specifically. All apps for iPhones should run on iPads but if the app is made specifically for an iPad it's not required to work on an iPhone/iPod.
What this means is this - if you use Storyboard with AutoLayout, emulating an iPhone 5+ screen type and dont define proper constrains manually you will literally loose bottom part of the screen without any errors or anything when the app is ran on an earlier iPhone (like, iPhone 4s which also got the iOS 8 update) or an iPad. It will just get cut-off.
You should use AutoLayout to define constrains between screen bounds and elements themselves. You have two options on how to handle difference is the screen height:
Once you start specifying constrains manually on Storyboard, XCode will try and assist you by letting you know if it needs more constrains or you're good to go. Lack of warnings is a good indicator that you are on the right path.
Define constrains by pressing Crtl + Left Mouse click
on an element, then drag the mouse towards the direction of constraint. You might want to do a simple tutorial to figure this out.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句