Andrew Duncan
Andrew Duncan

Reputation: 3753

What are gray constraints in Xcode view hierarchy debug view?

I know what the solid ones are: I created them myself. What about the gray ones? Implicit, maybe via size-to-fit? The gray height conflicts with the solid height. Where do the gray ones come from?

screen shot from Xcode

Upvotes: 22

Views: 4207

Answers (2)

Ulaş Sancak
Ulaş Sancak

Reputation: 907

I was facing this issue because I added subviews to UIStackView using addSubview instead of addArrangedSubview. -_-

Upvotes: 0

matt
matt

Reputation: 535889

You are inspecting an object such as a label that has an intrinsic content size. The intrinsic content size generates height and width constraints; that's what intrinsic content size is. The constraints in gray are showing you the constraints that the intrinsic content size generates. If you just look at them, you can see that: they say "content size"!

They are in gray because they are overridden by your explicit constraints (they have a lower priority). But they are still there, and if you were not overriding them, they would take effect (and they would not be gray).

Upvotes: 20

Related Questions