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

  1. <tfoot id='ElcOR'></tfoot>
        <bdo id='ElcOR'></bdo><ul id='ElcOR'></ul>

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

    1. <legend id='ElcOR'><style id='ElcOR'><dir id='ElcOR'><q id='ElcOR'></q></dir></style></legend>

      使用自动布局水平对齐 5 个按钮的最佳方法是什么

      What is the best approach for horizontally aligning 5 buttons with Autolayout(使用自动布局水平对齐 5 个按钮的最佳方法是什么)

      • <small id='3RLBB'></small><noframes id='3RLBB'>

        <tfoot id='3RLBB'></tfoot>
          <legend id='3RLBB'><style id='3RLBB'><dir id='3RLBB'><q id='3RLBB'></q></dir></style></legend>
          <i id='3RLBB'><tr id='3RLBB'><dt id='3RLBB'><q id='3RLBB'><span id='3RLBB'><b id='3RLBB'><form id='3RLBB'><ins id='3RLBB'></ins><ul id='3RLBB'></ul><sub id='3RLBB'></sub></form><legend id='3RLBB'></legend><bdo id='3RLBB'><pre id='3RLBB'><center id='3RLBB'></center></pre></bdo></b><th id='3RLBB'></th></span></q></dt></tr></i><div id='3RLBB'><tfoot id='3RLBB'></tfoot><dl id='3RLBB'><fieldset id='3RLBB'></fieldset></dl></div>
              <tbody id='3RLBB'></tbody>
              <bdo id='3RLBB'></bdo><ul id='3RLBB'></ul>
              1. 本文介绍了使用自动布局水平对齐 5 个按钮的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道这是一个新手风格的小问题,但我找不到任何主题,我必须在视图控制器中水平对齐多个按钮.

                I know this is a little newbie style question but I couldn't find any subject about this and I have to horizontally align multiple buttons in my view controller.

                我尝试了 2 种方法,第一种方法是将它们与 UIViews 和 <= 宽度更改约束优先级等分开.第二个没有 UIViews 但按钮在右舷对齐得很好.我已经看过斯坦福汽车布局课程.但我找不到任何解决方案.我不知道如何对齐多个按钮或视图,有人可以帮助我学习和解决这个问题吗?

                I tried to 2 approach first one is separate them with UIViews and <= width changed constraints priority and others. Second one doesn't have UIViews but buttons aligned in starboard very well. I already watched Stanford auto layout lessons. But I couldn't find any solution about this. I don't know how to approach to align multiple buttons or views can someone help me to learn and solve this problem ?

                谢谢!

                推荐答案

                你只需要在相邻按钮之间给出前导、尾随和等宽约束.

                You just need to give leading, trailing and equal-widths constraints between adjacent buttons.

                步骤(这里我们只考虑水平约束):

                1. 将第一个按钮的前导约束添加到父视图(或左侧同级视图).
                2. 在以下之间添加水平间距约束:
                  • 第一个按钮和第二个按钮.
                  • 第二个按钮和第三个按钮.
                  • 第三个按钮和第四个按钮.
                  • 第四个按钮和第五个按钮.
                • 第一个按钮和第二个按钮.
                • 第二个按钮和第三个按钮.
                • 第三个按钮和第四个按钮.
                • 第四个按钮和第五个按钮.

                如果您采用这种方法,则无需添加额外的视图来对齐按钮.请查看下面的屏幕截图以更好地理解这一点.

                If you follow this approach, you need not add extra views to align the buttons. Please see the screenshots below for understanding this better.

                这篇关于使用自动布局水平对齐 5 个按钮的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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屋-程序员

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

                          <tfoot id='l48xw'></tfoot>

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

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