2

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.
alessandrio
  • 4,282
  • 2
  • 29
  • 40
Aashish Nagar
  • 1,207
  • 1
  • 14
  • 30

2 Answers2

9

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
Rish K
  • 664
  • 7
  • 14
0

Did you try to set the view.frame property? Here is an exapmple:

How do I change UIView Size?