iOS iPhone 6 Autolayout - Full Width and Height

与世无争的帅哥 提交于 2019-12-25 04:32:15

问题


I designed my app to work on iPhone 5 and now want to make it compatible with iPhone 6 screens.

When I change the simulated metrics size to iphone 5.5 inch in the storyboard, I see that my view is no longer the full width and height of the screen.

How do I specify that the width and height should be the full screen dimensions?


回答1:


Don't change the simulated metrics. Just pick one (iPhone 5 is good, or you can even go with the default 600x600 layout) and leave it there. Make sure auto layout is turned on for the storyboard or xib (the File Inspector - first tab on the right side). Now set up auto layout constraints on each subview so they know what to do when the main view is resized for the iPhone 6 or 6 Plus screen sizes.

If you want to see what a view looks like in Interface Builder, again, don't change the simulated metrics. Instead, show the assistant editor and select Preview from the popup selection menu at the top left of the assistant editor view (it probably says Manual before you change it). Then you can use the + button at the bottom of that view to pick different phone sizes. You can even rotate them.

Here's a good place to get started with auto layout: http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1




回答2:


If you want design your app for different size classes...The best approach would be start with wAny hAny size class....

If you want to get full height and width of the view then just pinned all edges of the view and If you want to centralize your image inside that view then just use horizontal center and vertical center and give width and height to it...here is the example how you can make it

And the output in different size classes(4.7 and 5.5)...



来源:https://stackoverflow.com/questions/30560814/ios-iphone-6-autolayout-full-width-and-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!