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

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

        <bdo id='mGp18'></bdo><ul id='mGp18'></ul>
      <i id='mGp18'><tr id='mGp18'><dt id='mGp18'><q id='mGp18'><span id='mGp18'><b id='mGp18'><form id='mGp18'><ins id='mGp18'></ins><ul id='mGp18'></ul><sub id='mGp18'></sub></form><legend id='mGp18'></legend><bdo id='mGp18'><pre id='mGp18'><center id='mGp18'></center></pre></bdo></b><th id='mGp18'></th></span></q></dt></tr></i><div id='mGp18'><tfoot id='mGp18'></tfoot><dl id='mGp18'><fieldset id='mGp18'></fieldset></dl></div>
      <tfoot id='mGp18'></tfoot>
      1. AutoLayout 理解乘数

        AutoLayout Understanding Multiplier(AutoLayout 理解乘数)

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

                <tbody id='3zzRR'></tbody>
            • <tfoot id='3zzRR'></tfoot>

                  <small id='3zzRR'></small><noframes id='3zzRR'>

                  本文介绍了AutoLayout 理解乘数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对乘数有疑问,无法理解此功能的工作原理.例如,我的视图有 6:1 乘数(到 SuperView.Leading),如下所示.

                  I have a problem with multiplier and cannot understand how this feature works. For example i have view has 6:1 multiplier(To SuperView.Leading) as below.

                  当我将乘数更改为 2:1 时,如下图所示.

                  When i change the multiplier to 2:1 it seems like below picture.

                  我的问题是在 6:1 关系中 6 和 1 是什么意思.在 2:1 关系中,2 和 1 是什么意思.类似的考虑你有如下图所示的三个视图.subViews 和 superView 之间总共有 4 个空白区域.我怎么说每个空白区域都必须是 SuperView.Width/6 (并且每个空白宽度必须相等)

                  My question is in the 6:1 relation what does 6 and 1 mean. And also in 2:1 relation what does 2 and 1 mean. Similar consider you have three view like the picture below. Totally there 4 blank areas between subViews and superView. How can i say every blank area must be the SuperView.Width / 6 (and every blank width must be equal)

                  提前致谢.

                  推荐答案

                  在使用自动布局时,尤其是在使用比例布局时,必须使用乘数.

                  When working with autolayout, especially when you are working with proportional layouts, you have to use multiplier.

                  我必须在这里解释一些数学.我们知道直线方程.

                  I have to explain here some mathematics. We know straight line equation.

                  Y = Mx + C

                  在上面的等式中.假设 M 是您的乘数,C 是您的常数.

                  In above equation. Assume M is your multiplier and C is your Constant.

                  因此假设你有 superview(在 iphone 6s plus 的情况下)414(宽)x 736(高)尺寸.假设您在该视图上创建了子视图.

                  Thus suppose you have superview (in case of iphone 6s plus) of 414(width) x 736(height) size. On that view suppose you created subview.

                  现在,如果您希望子视图大小正好是父视图大小的一半,那么只需将两个约束从子视图拖到父视图.(即等宽等高)

                  Now if you want subview size exacly half of superview size, then just drag two constraints from subview to superview. (i.e. Equal Width and Equal Height)

                  看这张图片

                  显然现在你会得到一个错误.就像我得到的一样.(见下图)

                  Obviously now you will get an error. just like I'm getting. (See below Image)

                  现在一个一个地点击这两个约束,并使用乘数为 0.5.然后使用上面的直线方程.这里 0.5 表示您想要子视图的宽度 = superviewWidth/2.0 即 207 像素.

                  Now click on both of the constraints one by one, and use multiplier as 0.5. Then use above straight line equation. Here 0.5 means you want width of subview = superviewWidth / 2.0 i.e. 207 px.

                  换句话说,您也可以提供乘数为 207:414.

                  In other words you can provide multiplier as 207:414 also.

                  Y 即 subviewWidth = ((M i.e. 0.5) * (x i.e. 414 i.e. superviewWidth)) + (Constant i.e. 0)

                  Y i.e. subviewWidth = ((M i.e. 0.5) * (x i.e. 414 i.e. superviewWidth)) + (Constant i.e. Zero)

                  最后你得到 subviewWidth = 207 px

                  Finally you get subviewWidth = 207 px

                  子视图的高度也类似.提供乘数 0.5 或 368:736.

                  Similarly do for height of subview. Provide multiplier 0.5 or 368:736.

                  完成所有操作后,别忘了点击子视图并更新框架.

                  这样常量和乘数就可以工作了.

                  This way constants and multiplier will works.

                  这篇关于AutoLayout 理解乘数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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. <tfoot id='wK9f6'></tfoot>

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

                      <tbody id='wK9f6'></tbody>

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