What are gray constraints in Xcode view hierarchy debug view?

前端 未结 3 1909
轮回少年
轮回少年 2021-02-12 22:52

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 g

相关标签:
3条回答
  • 2021-02-12 23:34

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

    0 讨论(0)
  • 2021-02-12 23:50

    For me the gray constraints appeared because I was modifying the UIView's size outside the main thread.

    Make sure you don't make the same mistake:

    DispatchQueue.main.async {
       //modify your view here
    }
    
    0 讨论(0)
  • 2021-02-12 23:55

    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).

    0 讨论(0)
提交回复
热议问题