Autolayout - 如何更改iPhone 6和Plus之间的宽度间距 [英] Autolayout - How to Change width spacing between iPhone 6 and Plus

查看:274
本文介绍了Autolayout - 如何更改iPhone 6和Plus之间的宽度间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我已经把头发拉了几天了,我想我会问社区如何处理xco​​de 6.4或7中的宽度尺寸或按钮之间的间隙(两者都试过)。

Ok, I have been pulling my hair out for a few days now and thought I would ask the community how to deal with width sizes or the gaps between buttons in xcode 6.4 or 7 (tried them both).

理想情况下,我想要靠近底部的2个按钮,他们需要根据iPhone纵向模式正确缩放。

Ideally I want 2 buttons near the bottom and they need to scale properly based upon iPhone portrait mode.

我已将按钮的1x,2x和3x png添加到资产系统,我的自动布局设置为wCompact hRegular,根据我的理解,您可以使用以纵向模式定位所有iPhone设备。

I have added the 1x, 2x, and 3x pngs of the button to the asset system and my auto layout is set for wCompact hRegular which from what I understand allows you to target all iPhone devices in portrait mode.

所以在添加我的按钮之后,我确实添加了缺少的约束,这增加了几个并且似乎工作得很好但问题是我正在运行into是4.7英寸和5.5英寸之间的间隙间距以及如何在界面构建器中单独调整每个间距。

So after adding my buttons I had it do add missing constraints which added a few and seemed to work pretty good but the issue im running into is the gap spacing between the 4.7 inch and 5.5 inch and how to adjust each one of those separately in interface builder if possible.

请参阅下面的图片5.5英寸的空间和相当巨大的空间。

See the image below where I outline the gab space and its quite huge for the 5.5 inch.

如果我可以为更大的手机使用更大的图像,那将是非常棒的,但我认为这是另一个主题。

Also it would be awesome if I could use bigger images for the bigger phone but thats another subject I guess.

由于我无法在此处发布图片,因此链接到故事板

Since I cant post images here here is the link to the story board

推荐答案

看看这个存储库..

https://github.com/mahesh-agrawal/Test-Autolayout-Buttons-Spacing

我添加了必要的约束,以使所有设备的按钮之间存在动态差距。我也通过给出比例宽度高度来使宽度和高度动态化。

i have added required constraints to make the gap between the buttons dynamic for all devices. also i have made the width and height dynamic by giving proportional width height.

我已经拍摄了两个视图并给出了它们的水平间距0和相等的宽度以及前导和尾随所需的每。然后我在每个按钮中取两个按钮并按照视图的比例管理按钮的宽度,这样它们就会相应增加,而且间隙也会相应增加。在所有设备上进行测试。

I have taken two views and given them horizontal spacing 0 and equal width and leading and trailing required for each. and then i have taken two buttons in each and managing width of button with proportional to the views so they will increase accordingly and also the gap will increase accordingly. Test in all devices.

这篇关于Autolayout - 如何更改iPhone 6和Plus之间的宽度间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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