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

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

        <bdo id='asxOC'></bdo><ul id='asxOC'></ul>
    1. <tfoot id='asxOC'></tfoot>
      <legend id='asxOC'><style id='asxOC'><dir id='asxOC'><q id='asxOC'></q></dir></style></legend>

      iOS自动布局:两个等宽的按钮,并排

      iOS Autolayout: two buttons of equal width, side by side(iOS自动布局:两个等宽的按钮,并排)

          <tbody id='T2GyC'></tbody>
          <bdo id='T2GyC'></bdo><ul id='T2GyC'></ul>

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

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

              • 本文介绍了iOS自动布局:两个等宽的按钮,并排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我目前在使用 AutoLayout 时遇到困难.我正在使用界面生成器,并尝试将两个等宽的按钮并排放置,如下图所示.

                I am currently having difficulty with AutoLayout. I am using interface builder and am trying to position two buttons of equal width side by side as illustrated in the following image.

                从下面的预览图像中,我的 titleImage 已得到适当的约束并且可以正确显示,但按钮却没有.我已经尝试将按钮 1 与 titleImage 的前缘对齐,将 button2 与 titleImage 的后缘对齐,但是此时两个按钮之间的宽度分布变得倾斜,如下所示.

                From the following Preview image, my titleImage has been properly constrained and is displaying correctly however the buttons are not. I have experimented by aligning button 1 with the leading edge of titleImage, and button2 with the trailing edge of titleImage, however the width distribution between the two buttons becomes skewed at this point, as demonstrated below.

                我的目标是了解缺少哪些约束,并应将其应用于两个按钮以保持相同的宽度,而不管设备如何.如果可能的话,我想通过界面生成器而不是附加代码来实现这一点.

                My objective is to understand what constraints are missing and should be applied to the two buttons to maintain equal widths regardless of device. If possible I would like to achieve this through interface builder as opposed to additional code.

                推荐答案

                添加如下约束

                1. 从 button1 到 button2 分配相等的宽度.
                2. 在两个按钮之间分配水平间距.
                3. 将 button1 的前导空格分配给其父视图.
                4. 将 button2 的尾随空格分配给其父视图.
                5. 为两个按钮分配顶部空间.<小时>请让我知道这对你有没有用.

                这篇关于iOS自动布局:两个等宽的按钮,并排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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屋-程序员
                    <tbody id='Rs00N'></tbody>

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

                  2. <tfoot id='Rs00N'></tfoot>

                      <bdo id='Rs00N'></bdo><ul id='Rs00N'></ul>

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