How can I make all elements of a view be entered proportionally to the screen(xCode 6, using swift)?

GuiGui23

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.

C0D3LIC1OU5

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:

  1. One or more elements have flexible heights to make sure they stretch to fill up extra spaces for iPhones 5+ while also looking fine on iPhones <= 4 and iPads. This will require you to define vertical space between the top of the screen, all elements from the top to the bottom, and the bottom of the screen. Define height constrains for elements you do not want to stretch. This is also the proper way to use AutoLayout with scroll views.
  2. Or anchor one or more element to the top or bottom of the screen, and specify vertical constrains to elements below/above it. You will need to specify the heights for all elements if you want to do it this way.

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How can I show entered password using tooltip on input type=password in bootstrap?

来自分类Dev

How can I apply a jQuery function to all elements with the same class.?

来自分类Dev

SWIFT: How I can use subscriberCellularProviderDidUpdateNotifier with Swift

来自分类Dev

How to make both header and footer in collection view with swift

来自分类Dev

How can I use sed to make thousands of substitutions in a file using a reference file?

来自分类Dev

How can I make this Makefile more generic?

来自分类Dev

Can I avoid calculating same elements when using split() in Halide?

来自分类Dev

How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner?

来自分类Dev

How can I exclude last two child elements with CSS selector?

来自分类Dev

How can I fetch a database, then show the result in a view?

来自分类Dev

How can I "slide up" a view on android from the bottom of a screen?

来自分类Dev

How can i redirect the page in razor view .cshtml?

来自分类Dev

How can I view the active threads of a running program?

来自分类Dev

How can I make two iframes fit the width of the page?

来自分类Dev

Sensitivity analysis with R: How can I make my own plot

来自分类Dev

How can I make JSSOR change its aspect ratio?

来自分类Dev

How can I create a php function that will gather all

来自分类Dev

How can i get the fileinfo of all files in a folder with GetFile()?

来自分类Dev

How can I replace all occurrences of the division sign with a slash in Java?

来自分类Dev

How can I show the size of all files in my ~/.cache directory?

来自分类Dev

How can I identify uppercase and lowercase characters in a string with swift?

来自分类Dev

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

来自分类Dev

How can I get the x/y location of a touch relative to the entire view when I touch a button?

来自分类Dev

How to delete all records of a table in MS Access using VB6 ADO

来自分类Dev

In C#, how can I keep all my items in a listbox from changing to the color I set last?

来自分类Dev

AdMob banner using swift in xcode 6

来自分类Dev

How can I get the current weekday in Rust using the Chrono crate?

来自分类Dev

How can I center text inside a div element using CSS

来自分类Dev

How can I create a temporary table using PetaPoco?

Related 相关文章

  1. 1

    How can I show entered password using tooltip on input type=password in bootstrap?

  2. 2

    How can I apply a jQuery function to all elements with the same class.?

  3. 3

    SWIFT: How I can use subscriberCellularProviderDidUpdateNotifier with Swift

  4. 4

    How to make both header and footer in collection view with swift

  5. 5

    How can I use sed to make thousands of substitutions in a file using a reference file?

  6. 6

    How can I make this Makefile more generic?

  7. 7

    Can I avoid calculating same elements when using split() in Halide?

  8. 8

    How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner?

  9. 9

    How can I exclude last two child elements with CSS selector?

  10. 10

    How can I fetch a database, then show the result in a view?

  11. 11

    How can I "slide up" a view on android from the bottom of a screen?

  12. 12

    How can i redirect the page in razor view .cshtml?

  13. 13

    How can I view the active threads of a running program?

  14. 14

    How can I make two iframes fit the width of the page?

  15. 15

    Sensitivity analysis with R: How can I make my own plot

  16. 16

    How can I make JSSOR change its aspect ratio?

  17. 17

    How can I create a php function that will gather all

  18. 18

    How can i get the fileinfo of all files in a folder with GetFile()?

  19. 19

    How can I replace all occurrences of the division sign with a slash in Java?

  20. 20

    How can I show the size of all files in my ~/.cache directory?

  21. 21

    How can I identify uppercase and lowercase characters in a string with swift?

  22. 22

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

  23. 23

    How can I get the x/y location of a touch relative to the entire view when I touch a button?

  24. 24

    How to delete all records of a table in MS Access using VB6 ADO

  25. 25

    In C#, how can I keep all my items in a listbox from changing to the color I set last?

  26. 26

    AdMob banner using swift in xcode 6

  27. 27

    How can I get the current weekday in Rust using the Chrono crate?

  28. 28

    How can I center text inside a div element using CSS

  29. 29

    How can I create a temporary table using PetaPoco?

热门标签

归档