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

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

  • <tfoot id='wrlv8'></tfoot>

        <legend id='wrlv8'><style id='wrlv8'><dir id='wrlv8'><q id='wrlv8'></q></dir></style></legend>
          <bdo id='wrlv8'></bdo><ul id='wrlv8'></ul>

        如何获得自动布局来覆盖 UIImageView 的固有大小?

        时间:2024-04-14

        <tfoot id='WxUR4'></tfoot>

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

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

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

            • <legend id='WxUR4'><style id='WxUR4'><dir id='WxUR4'><q id='WxUR4'></q></dir></style></legend>
                <tbody id='WxUR4'></tbody>
                  本文介绍了如何获得自动布局来覆盖 UIImageView 的固有大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 UISplitViewController 中的详细视图的自动布局方面遇到了问题.我的视图层次结构包含一个带有装饰元素的 UIImageView,并且图像视图的固有大小似乎搞砸了其余控件的布局.

                  I'm running into a problem with the autolayout for my detail view in a UISplitViewController. My view hierarchy contains a UIImageView with a decorative element, and the image view's intrinsic size seems to be screwing up the layout of the rest of the controls.

                  这些是我为图像视图指定的约束:

                  These are the constraints I have specified for the image view:

                  H:[UIImageView:0xc83ba90]-(NSSpace(20))-|
                  H:|-(NSSpace(20))-[UIImageView:0xc83ba90]
                  UIImageView:0xc83ba90.bottom == UITextField:0xc83d2d0.bottom
                  V:[UIImageView:0xc83ba90 (3)]>,
                  H:[UIImageView:0xc83ba90 (532)] Hug:1 CompressionResistance:750
                  V:[UIImageView:0xc83ba90 (2)] Hug:250 CompressionResistance:750
                  

                  我想要的行为是调整图像视图的大小以填充其父视图,如前两个约束所述.我看到的实际行为是图像视图只占用由其固有大小约束描述的水平空间.它似乎也在改变其所有同级视图的布局,就好像超级视图只是在一个与图像视图一样宽的矩形中布置视图.

                  The behavior I want is for the image view to be resized to fill its superview, as described by the top two constraints. The actual behavior I'm seeing is that the image view only takes up horizontal space described by its intrinsic size constraint. It also seems to be altering the layout of all of its sibling views, as though the superview were only laying out views in a rectangle as wide as the image view.

                  我认为尽可能低地指定图像视图的拥抱优先级会让其他约束覆盖它以调整图像视图的大小.我在这里做错了什么?

                  I thought that specifying the hugging priority of the image view as low as possible would let the other constraints override it to resize the image view. What am I doing wrong here?

                  推荐答案

                  所以,我终于找到了解决方案.

                  So, I finally found a solution.

                  解决方法是将superview的Hugging Priority提高为.defaultHigh,将UIImageView的Compression Resistance Priority降低为.defaultLow.这将使约束覆盖图像的固有大小.

                  Solution is to increase the Hugging Priority of the superview to .defaultHigh and decrease the Compression Resistance Priority of the UIImageView to .defaultLow. This will let constraints override the image's Intrinsic Size.

                  Content Hugging Priority - 此优先级越高,视图越能抵抗增长超过其固有内容大小.

                  Content Hugging Priority - The higher this priority is, the more a view resists growing larger than its intrinsic content size.

                  内容压缩阻力优先级 - 此优先级越高,视图越能抵抗缩小到小于其固有内容大小的程度.

                  Content Compression Resistance Priority - The higher this priority is, the more a view resists shrinking smaller than its intrinsic content size.

                  这篇关于如何获得自动布局来覆盖 UIImageView 的固有大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为 UIImageView 修饰内部 下一篇:无法加载从带有标识符的包中的笔尖引用的图像

                  相关文章

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

                    <tfoot id='V5LuQ'></tfoot>

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

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

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