Get safe area inset top and bottom heights

后端 未结 15 1431
长发绾君心
长发绾君心 2020-11-30 17:30

On the new iPhone X, what would be the most proper way to get both top and bottom height for the unsafe areas?

15条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 17:53

    safeAreaLayoutGuide When the view is visible onscreen, this guide reflects the portion of the view that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. (In tvOS, the safe area reflects the area not covered the screen's bezel.) If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the layout guide edges are equal to the edges of the view.

    Then to get the height of the red arrow in the screenshot it's:

    self.safeAreaLayoutGuide.layoutFrame.size.height
    

提交回复
热议问题