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

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

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

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

        中心 4 个带有约束自动布局的图像

        Center 4 images with constraints autolayout(中心 4 个带有约束自动布局的图像)
        <i id='FAnCq'><tr id='FAnCq'><dt id='FAnCq'><q id='FAnCq'><span id='FAnCq'><b id='FAnCq'><form id='FAnCq'><ins id='FAnCq'></ins><ul id='FAnCq'></ul><sub id='FAnCq'></sub></form><legend id='FAnCq'></legend><bdo id='FAnCq'><pre id='FAnCq'><center id='FAnCq'></center></pre></bdo></b><th id='FAnCq'></th></span></q></dt></tr></i><div id='FAnCq'><tfoot id='FAnCq'></tfoot><dl id='FAnCq'><fieldset id='FAnCq'></fieldset></dl></div>

            <tbody id='FAnCq'></tbody>
              <legend id='FAnCq'><style id='FAnCq'><dir id='FAnCq'><q id='FAnCq'></q></dir></style></legend>

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

              <tfoot id='FAnCq'></tfoot>
              • <bdo id='FAnCq'></bdo><ul id='FAnCq'></ul>

                  本文介绍了中心 4 个带有约束自动布局的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是自动布局的新手,我有点纠结于如何将这 4 个图像在所有不同的设备中居中,就像它在图像上的样子一样.我试图应用自动配置的约束,但它会有那个距离并且不适合所有设备.所以我的问题是我需要对所有不同的图像应用什么约束才能使所有图像以相同的距离居中?

                  I'm new to autolayout and i'm kind of stuck on how to center these 4 images in all different devices like it looks on the images. i've tried to apply the auto configured constraints but then it will have that distance and that does not fit on all devices. So my question is what constraints do i need to apply on all different images in order to make all image centered with same distance?

                  这是我在storyBoard中的单元格的样子:

                  Here is how my cell in storyBoard looks like:

                  图像 1 上的约束选项图像:

                  image of the constraint options on image 1:

                  模拟器中的图片:

                  ///我的尝试////

                  /// MY TRY ////

                  在这里你可以看到我添加的约束和结果?

                  Here you can see the constraints that i've added and the result?

                  结果:

                  推荐答案

                  您的方法几乎是正确的,它只是缺少图像的大小限制.

                  Your approach is almost correct, it simply lacks size constraints for the images.

                  如果您想动态调整图像大小并保持它们之间的空间不变,请将图像的宽度限制为 >=20(或任何其他值,取决于您的需要) 和保持纵横比的约束.然后 ctrl-drag 从 UIImageView1UIImageView2 并设置 equal widths 的约束.从 UIImageView1UIImageView3 以及从 UIImageView1UIImageView4 重复此操作.

                  If you want to dynamically resize the images and keep the space between them constant, put constraints on the images for the width to be >=20(or any other value, depends on your needs) and a constraint for keeping the aspect ratio. Then ctrl-drag from UIImageView1 to UIImageView2 and set a constraint for equal widths. Repeat that from UIImageView1 to UIImageView3 and from UIImageView1 to UIImageView4.

                  如果您希望图像始终保持其固定大小和动态大小的空间,则需要另一种方法:

                  If you want the images to always keep their fixed size and dynamically sized spaces between them you need another approach:

                  这里的技巧是在 UIImageViews 之间放置 3 个空的 UIViews,使其看起来像这样:

                  The trick here is to place 3 empty UIViews between the UIImageViews so that it looks like this:

                  • 为所有视图设置顶部约束
                  • 为 UIImageView1 和 4 设置左右约束
                  • 将所有 UIImageView 的约束设置为相同的宽度
                  • 将 UIImageView 之间的所有 UIView 的约束设置为相同的宽度
                  • 将视图之间所有距离的约束设置为 0
                  • 将 UIView 的宽度限制设置为 >= 0

                  这种方式使得 UIImageViews 之间的空 UIViews 可以动态调整大小并且宽度都相同.

                  This way makes the empty UIViews between the UIImageViews to resize dynamically and all the same width.

                  希望你能明白.

                  这篇关于中心 4 个带有约束自动布局的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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屋-程序员
                1. <small id='LIjMZ'></small><noframes id='LIjMZ'>

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