[英]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.