简体   繁体   English

当Superview高度常量设置为零时,如何完全隐藏内部视图

[英]How to hide inner view completely when superview height constant is set to zero

在此处输入图片说明

As you can see, I have a UIView(red color) that has constraints - leading, bottom, width and height. 如您所见,我有一个具有约束条件的UIView(红色)-前导,底部,宽度和高度。 All set to default(1000) priorities except height(999). 除高度(999)外,所有优先级均设置为默认(1000)优先级。 Inside this UIView are three UIButtons those have constraints - leading, top, width and height. 此UIView内有三个具有约束的UIButton-前导,顶部,宽度和高度。 All set to default(1000) priorities except height (2). 除高度(2)外,所有优先级均设置为默认(1000)优先级。 So that superview's height can override the innerviews height. 这样,超级视图的高度可以覆盖内部视图的高度。 At the click of orange button. 单击橙色按钮。 I set UIView's height constant to 0. 我将UIView的高度常数设置为0。

And the result is this - in pic below. 结果是这样的-在下面的图片中。 At bottom you can see content(text) is not compressed to hide itself. 在底部,您可以看到content(text)未被压缩以隐藏自身。 What should I do. 我该怎么办。 I have played with vertical compression resistance. 我玩过垂直压缩阻力。 Please don't say set buttons to hidden etc. 请不要说将按钮设置为隐藏等。

在此处输入图片说明

// Orange Button Action Clicked //单击橙色按钮动作

@IBAction func orangeAction(_ sender: Any) @IBAction func orangeAction(_发送方:任意)
{ {

redViewHeight.constant = 0 redViewHeight.constant = 0

redView.clipsToBounds = true redView.clipsToBounds = true

} }

// ClipTo bound : the subview that fits within the bounds of the superview. // ClipTo bound:适合父视图范围的子视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当UIView高度设置为零时,视图的子控件不会隐藏 - When UIView height set zero, view's child control not hide 如何在 SwiftUI 中按比例设置高度和宽度? - How to set height and width in proportion with superview in SwiftUI? 如何设置自动布局约束,以使UIImageView的高度等于超级视图的高度? - How to set autolayout constraint so that the height of an UIImageView is equal to the height of the superview? 如何设置AutoLayout约束的常量占父视图的百分比? - How can I set AutoLayout constraints' constant as a percentage of the superview? 如何根据内部视图出口自动设置表格单元格行高? - how to set tablecell row height automatically based on inner view outlet? 视图和超级视图自动布局的比例高度 - proportional height of view and superview autolayout 如何在SnapKit中按比例设置边缘偏移量与超视图高度的大小 - how to set edge offset proportionally to size of superview height in SnapKit 如何将 UILabel 高度设置为零 - How to set UILabel height to zero 如何隐藏 UIView 并在 swift 中为 UITable 视图设置新高度? - How to hide a UIView and set new height to UITable view in swift? 使用自动布局约束时,在超视图高度更改时隐藏子视图 - Hide subviews when superview height change while using auto layout constraints
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM