1. <tfoot id='6n8g5'></tfoot>
    <i id='6n8g5'><tr id='6n8g5'><dt id='6n8g5'><q id='6n8g5'><span id='6n8g5'><b id='6n8g5'><form id='6n8g5'><ins id='6n8g5'></ins><ul id='6n8g5'></ul><sub id='6n8g5'></sub></form><legend id='6n8g5'></legend><bdo id='6n8g5'><pre id='6n8g5'><center id='6n8g5'></center></pre></bdo></b><th id='6n8g5'></th></span></q></dt></tr></i><div id='6n8g5'><tfoot id='6n8g5'></tfoot><dl id='6n8g5'><fieldset id='6n8g5'></fieldset></dl></div>
    1. <small id='6n8g5'></small><noframes id='6n8g5'>

    2. <legend id='6n8g5'><style id='6n8g5'><dir id='6n8g5'><q id='6n8g5'></q></dir></style></legend>

        <bdo id='6n8g5'></bdo><ul id='6n8g5'></ul>

      clipsToBounds 在 UIStackView 中似乎没有效果

      clipsToBounds seeming to have no effect in UIStackView(clipsToBounds 在 UIStackView 中似乎没有效果)
        <bdo id='mrMXk'></bdo><ul id='mrMXk'></ul>

                  <tbody id='mrMXk'></tbody>
              1. <small id='mrMXk'></small><noframes id='mrMXk'>

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

                <tfoot id='mrMXk'></tfoot>
              3. 本文介绍了clipsToBounds 在 UIStackView 中似乎没有效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以在 UIStackView 之外呈现子视图?我有一个带有按钮和标签的垂直堆栈视图,并且我正在使用堆栈视图的宽度来适当地设置按钮的高度和宽度:

                Is it possible to have a subview render outside a UIStackView? I have a vertical stack view with a button and a label, and I'm using the width of the stack view to set the button's height and width appropriately:

                addArrangedSubview(self.loginMethodButton)
                let widthConstraint = NSLayoutConstraint(item: self.loginMethodButton, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1.0, constant: 0.0)
                let heightConstraint = NSLayoutConstraint(item: self.loginMethodButton, attribute: .height, relatedBy: .equal, toItem: self.loginMethodButton, attribute: .width, multiplier: 1.0, constant: 0.0)
                NSLayoutConstraint.activate([widthConstraint, heightConstraint])
                

                然后我根据情况将 viewController 中的宽度调整为适当的大小.问题是,在按钮需要的较小尺寸之一中,宽度小于其下方的标签,这会切断标签.

                I then adjust the width in my viewController to appropriate sizes based on the situation. The problem is, in one of the smaller sizes the button needs to be, the width is smaller than the label beneath it, which cuts off the label.

                如果我在设置标签时调用 sizeToFit() ,它可以工作,但是,在设置标签后调整大小时调用 sizeToFit() 仍然会导致标签被切断.在标签和堆栈视图上将 clipsToBounds 设置为 false 无效.

                If I call sizeToFit() when setting the label, it works, however, calling sizeToFit() when adjusting the sizes after the label has been set still results in the label being cut off. Setting clipsToBounds to false on both the label and stack view have no effect.

                是否可以在堆栈视图之外渲染视图?或者我是否必须找到一种方法来重新处理我的约束以解决这个问题?

                Is it possible to render a view outside of a stack view at all? Or am I going to have to find a way to re-work my constraints in order to fix this issue?

                推荐答案

                UIStackView 是一个非渲染"对象......它所做的只是安排其他视图.

                UIStackView is a "non-rendering" object... all it does is arrange other views.

                如果问题是您的 UILabel 太宽而无法放入 Stack View 提供的区域,那么您需要将标签设置为自动缩小"字体,或者您需要更改 Stack View 约束以允许使用更宽的标签.

                If the problem is that your UILabel is too wide to fit in the area made available by your Stack View, then you either need to set the label to "auto-shrink" the font, or you need to alter your Stack View constraints to allow for the wider label.

                编辑 根据您的其他评论,以下内容不正确.

                您需要在包含"视图上设置 .clipsToBounds...根据您显示的图形,这将是深蓝色框(我假设这是一个 UIView 将图像和标签作为子视图).

                You need to set .clipsToBounds on the "containing" view... based on the graphic you are showing, that would be the darker-blue box (I'm assuming that is a UIView with the image and label as subviews).

                这篇关于clipsToBounds 在 UIStackView 中似乎没有效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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屋-程序员
                <i id='3yY0U'><tr id='3yY0U'><dt id='3yY0U'><q id='3yY0U'><span id='3yY0U'><b id='3yY0U'><form id='3yY0U'><ins id='3yY0U'></ins><ul id='3yY0U'></ul><sub id='3yY0U'></sub></form><legend id='3yY0U'></legend><bdo id='3yY0U'><pre id='3yY0U'><center id='3yY0U'></center></pre></bdo></b><th id='3yY0U'></th></span></q></dt></tr></i><div id='3yY0U'><tfoot id='3yY0U'></tfoot><dl id='3yY0U'><fieldset id='3yY0U'></fieldset></dl></div>
              4. <tfoot id='3yY0U'></tfoot>
                    <tbody id='3yY0U'></tbody>
                  <legend id='3yY0U'><style id='3yY0U'><dir id='3yY0U'><q id='3yY0U'></q></dir></style></legend>

                • <small id='3yY0U'></small><noframes id='3yY0U'>

                          <bdo id='3yY0U'></bdo><ul id='3yY0U'></ul>