What is _UILayoutGuide?

前端 未结 3 1437
感动是毒
感动是毒 2020-12-31 10:06

I need to know about _UILayoutGuide, like what it is, what it does and why it present in the hierarchy of UIView as a subview with alm

3条回答
  •  旧巷少年郎
    2020-12-31 10:30

    UILayoutGuides

    UILayoutGuides represent a rectangle in the layout engine. They will not show up in the view hierarchy, but may be used as items in an NSLayoutConstraint.

    iOS 9

    In iOS 9 Apple provides a new improved way of controlling negative space called a UILayoutGuide. A UILayoutGuide, or layout guide, is an empty rectangle in a layout against which constraints can be applied to define the it’s relationship to other UILayoutGuides or UIViews.

    UILayoutGuides don’t have a hierarchy and they are not part of the view hierarchy. They are owned by a UIView, but they cannot own a UIView or another UILayoutGuide. UILayoutGuides do not contain a CALayer and they are not a UIResponder. This means that there is no drawing overhead added to to the render phase by adding a UILayoutGuide and there is no impact on the UIEvent handling process by having a UILayoutGuide.

    Source:

    • UILayoutGuide – Auto Layout’s Invisible Helpers
    • UILayoutGuide.h

提交回复
热议问题