• <small id='b7Elh'></small><noframes id='b7Elh'>

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

      1. iOS自动布局使我的视图在两个视图之间居中

        时间:2023-09-11

          • <bdo id='8v5Av'></bdo><ul id='8v5Av'></ul>

              <legend id='8v5Av'><style id='8v5Av'><dir id='8v5Av'><q id='8v5Av'></q></dir></style></legend>
                <tfoot id='8v5Av'></tfoot>
              • <small id='8v5Av'></small><noframes id='8v5Av'>

                <i id='8v5Av'><tr id='8v5Av'><dt id='8v5Av'><q id='8v5Av'><span id='8v5Av'><b id='8v5Av'><form id='8v5Av'><ins id='8v5Av'></ins><ul id='8v5Av'></ul><sub id='8v5Av'></sub></form><legend id='8v5Av'></legend><bdo id='8v5Av'><pre id='8v5Av'><center id='8v5Av'></center></pre></bdo></b><th id='8v5Av'></th></span></q></dt></tr></i><div id='8v5Av'><tfoot id='8v5Av'></tfoot><dl id='8v5Av'><fieldset id='8v5Av'></fieldset></dl></div>
                  <tbody id='8v5Av'></tbody>
                  本文介绍了iOS自动布局使我的视图在两个视图之间居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 Interface Builder 中设置自动布局以垂直排列视图,如图所示:

                  How to set up autolayout in Interface Builder to arrange views vertically as shown on image:

                  Top view 固定在屏幕顶部边缘,Bottom view 固定在屏幕底部边缘.My view 应该在顶视图和底视图之间居中(因此到 Top view 的距离等于到 Bottom view 的距离)

                  Top view pinned to top screen edge, Bottom view pinned to bottom screen edge. My view should be centered between top and bottom views (so distance to Top view equals to distance to Bottom view)

                  推荐答案

                  这样做的方法是在可见视图之间放置 2 个不可见的间隔"视图.

                  The way to do this is to have 2 invisible "spacer" views between you visible views.

                  您不能使空间具有相同的高度.但是您使用间隔"视图并将它们放置在您的视图之间(与周围视图之间的间隙为 0).

                  You can't make spaces have equal height. But you use the "spacer" views and place them between your views (with 0 gap to the surrounding views).

                  然后你给这些视图相等的高度,它们会将你的视图围绕在 My View 的中心,与 Bottom ViewTop View.

                  Then you give these views equal heights and they will push your views around to centre the My View with equal gap to the Bottom View and Top View.

                  即像这样……

                  V:|[Top View][spacer1][My View][spacer2(==spacer1)][Bottom View]|
                  

                  编辑 - 另一种方式

                  我只是想到了另一种方法.您可以在 Top ViewBottom View 之间有一个不可见的容器 UIView,没有间隙.

                  I just thought of another way of doing this. You could have an invisible container UIView that is between Top View and Bottom View with no gap.

                  然后你将 My View 放在这个不可见的视图中并垂直居中.

                  Then you place My View inside this invisible view and centre it vertically.

                  这篇关于iOS自动布局使我的视图在两个视图之间居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  • <legend id='Wj1sB'><style id='Wj1sB'><dir id='Wj1sB'><q id='Wj1sB'></q></dir></style></legend>
                  • <small id='Wj1sB'></small><noframes id='Wj1sB'>

                      • <bdo id='Wj1sB'></bdo><ul id='Wj1sB'></ul>

                        <tfoot id='Wj1sB'></tfoot>

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