Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ForeceFully set view height to zero

I have a view which has many subview. Height of view is depend upon height of subViews.But in a case I want view to be of height 0 regardless of its subView height. I to achieve that. for example there is a view called view and it has 2 subView(image and label) view1 and view2. constraint are like this.

 view1.top = view.top + 1
view1.height = 30
view2.top = view1.bottom
view.bottom = view2.bottom.
like image 803
Aashish Nagar Avatar asked Aug 30 '26 02:08

Aashish Nagar


1 Answers

I think what you're are looking for is the heightAnchor.

https://developer.apple.com/reference/uikit/uiview/1622590-heightanchor

view.heightAnchor.constraint(equalToConstant: 0).isActive = true
like image 118
Rish K Avatar answered Aug 31 '26 17:08

Rish K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!