<i id='JnugL'><tr id='JnugL'><dt id='JnugL'><q id='JnugL'><span id='JnugL'><b id='JnugL'><form id='JnugL'><ins id='JnugL'></ins><ul id='JnugL'></ul><sub id='JnugL'></sub></form><legend id='JnugL'></legend><bdo id='JnugL'><pre id='JnugL'><center id='JnugL'></center></pre></bdo></b><th id='JnugL'></th></span></q></dt></tr></i><div id='JnugL'><tfoot id='JnugL'></tfoot><dl id='JnugL'><fieldset id='JnugL'></fieldset></dl></div>

        <small id='JnugL'></small><noframes id='JnugL'>

      1. <tfoot id='JnugL'></tfoot>

        <legend id='JnugL'><style id='JnugL'><dir id='JnugL'><q id='JnugL'></q></dir></style></legend>
        • <bdo id='JnugL'></bdo><ul id='JnugL'></ul>

        为按钮提供相等的宽度约束时,自动布局设置不正确

        Auto layout not set properly when give equal width constrains to buttons(为按钮提供相等的宽度约束时,自动布局设置不正确)

        <small id='z1xUr'></small><noframes id='z1xUr'>

          <tfoot id='z1xUr'></tfoot>

              • <bdo id='z1xUr'></bdo><ul id='z1xUr'></ul>
                <legend id='z1xUr'><style id='z1xUr'><dir id='z1xUr'><q id='z1xUr'></q></dir></style></legend>

                    <tbody id='z1xUr'></tbody>

                  <i id='z1xUr'><tr id='z1xUr'><dt id='z1xUr'><q id='z1xUr'><span id='z1xUr'><b id='z1xUr'><form id='z1xUr'><ins id='z1xUr'></ins><ul id='z1xUr'></ul><sub id='z1xUr'></sub></form><legend id='z1xUr'></legend><bdo id='z1xUr'><pre id='z1xUr'><center id='z1xUr'></center></pre></bdo></b><th id='z1xUr'></th></span></q></dt></tr></i><div id='z1xUr'><tfoot id='z1xUr'></tfoot><dl id='z1xUr'><fieldset id='z1xUr'></fieldset></dl></div>

                  本文介绍了为按钮提供相等的宽度约束时,自动布局设置不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我看到了许多解决方案并应用了自动布局约束,但我仍然没有得到想要的解决方案.

                  I see many solution and applied auto layout constrains but still i am not getting desired solution.

                  当前结果:

                  给所有按钮的约束:

                  查看层次结构:

                  推荐答案

                  假设您想要的是让 3 个按钮彼此相等并使用 Interface Builder 填充屏幕宽度(没有代码,即:不是以编程方式),这是一个解决方案:

                  Assuming that what do you want is letting the 3 buttons equal each others and filling the width of screen using the Interface Builder (with no code, i.e: not programmatically), this is a solution:

                  您不需要将它们添加到视图中.只需按照以下步骤操作:

                  you don't need to add them in views. just follow these steps:

                  让我们从这个开始:

                  请注意,按钮还没有任何约束,只需将它们添加到视图底部(或者您想要显示它们的任何位置,对于此解决方案,我将它们显示在底部屏幕).确保它们中的 3 个具有相同的大小.

                  note that the buttons don't have any constraints -yet-, just add them to the to the bottom of the view (or where ever you want to display them, for this solution, I will display them in bottom of the screen). Make sure that the 3 of them have the same size.

                  橙色按钮添加约束:

                  Adding constraints to the orange button:

                  添加以下约束:前导、底部空间和等高.

                  蓝色按钮添加约束:

                  Adding constraints to the blue button:

                  添加以下约束:尾随、底部空间和等高.

                  青色按钮添加约束:

                  Adding constraints to the cyan button:

                  • ctrl + 从青色按钮拖动到橙色按钮并添加以下约束:水平间距和垂直居中.

                  • ctrl + 从青色按钮拖动到蓝色按钮并添加以下约束:水平间距.

                  • 底部空间和等高.

                  到目前为止一切顺利,我们几乎完成了!

                  So far so good, we are almost done!

                  现在,选择 3 个按钮并添加以下约束:等宽.

                  Now, select the 3 buttons and add the following constraint: equal widths.

                  您的按钮应如下所示:

                  现在,您所要做的就是选择两个水平间距约束中的每一个,并将它们的常量设置为 0(来自尺寸检查器):

                  Now, all you have to do is select each of the two horizontal spacing constraints and set their constants to 0 -from the size inspector-:

                  你去吧:

                  我希望这会有所帮助,干杯.

                  I hope this helped, Cheers Up.

                  这篇关于为按钮提供相等的宽度约束时,自动布局设置不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                    <bdo id='mJv61'></bdo><ul id='mJv61'></ul>

                    <tfoot id='mJv61'></tfoot>
                      • <i id='mJv61'><tr id='mJv61'><dt id='mJv61'><q id='mJv61'><span id='mJv61'><b id='mJv61'><form id='mJv61'><ins id='mJv61'></ins><ul id='mJv61'></ul><sub id='mJv61'></sub></form><legend id='mJv61'></legend><bdo id='mJv61'><pre id='mJv61'><center id='mJv61'></center></pre></bdo></b><th id='mJv61'></th></span></q></dt></tr></i><div id='mJv61'><tfoot id='mJv61'></tfoot><dl id='mJv61'><fieldset id='mJv61'></fieldset></dl></div>
                          <tbody id='mJv61'></tbody>

                          1. <small id='mJv61'></small><noframes id='mJv61'>

                            <legend id='mJv61'><style id='mJv61'><dir id='mJv61'><q id='mJv61'></q></dir></style></legend>