与大小自动版式类:根据iPhone屏幕大小不同的间距 [英] AutoLayout with size classes: Different spacing depending on iPhone screen size

查看:279
本文介绍了与大小自动版式类:根据iPhone屏幕大小不同的间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的UIViewController 使用界面生成器设置在 UIStoryboard 大小类的。

I have a UIViewController set up in an UIStoryboard in Interface Builder using size classes.

这看起来在iPhone 5的4好的屏幕,但5.5的iPhone 6加屏幕的元素是在设备的顶部区域过于局促。我想增加iPhone 6,6加的空间约束的常数。

This looks good on an iPhone 5 with the 4" screen, but on the 5.5" screen of the iPhone 6 Plus the elements are too cramped in the top area of the device. I want to increase the constant of the spacing constraints on iPhone 6 and 6 Plus.

至于我能看到这是不可能的,大小班,因为只有我为人人iPhone显示屏大小的类(无论3.5或5.5)。什么是做到这一点的方式呢?或许真的与约束乘数?还没有真正计算过,一出。

As far as I was able to see that's not possible with size classes, as there is only one size class for all iPhone displays (no matter if 3.5" or 5.5"). What is the way to do this? Maybe something with the constraint multiplier? Still haven't really figured that one out.

推荐答案

在这里看到我的回答是:

See my answer here:

http://stackoverflow.com/a/20865342/341994

我解释那里,你不能让一个间距约束值取决于事物的高度。但是你可以做一个高度约束依赖于一些高度。因此,尝试将其高度是成正比的上海华高度的无形的观点,并把它作为一个垫片,以约束它。这将推动该意见按比例下降到屏幕的高度。

As I explain there, you can't make a spacing constraint value depend on the height of something. But you can make a height constraint depend on the height of something. So try adding an invisible view whose height is proportional to the superview height, and use it as a spacer, with constraints to it. This will push the views down proportionally to the screen height.

我做了一个快速演示。看红色视图的顶部是如何在iPhone 6再往下比它在iPhone 4S上:

I made a quick demo. Look at how the top of the red view is further down on the iPhone 6 than it is on the iPhone 4s:

这篇关于与大小自动版式类:根据iPhone屏幕大小不同的间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆