topLayoutGuide in child view controller

前端 未结 11 2099
既然无缘
既然无缘 2020-12-07 11:29

I have a UIPageViewController with translucent status bar and navigation bar. Its topLayoutGuide is 64 pixels, as expected.

However, the ch

11条回答
  •  误落风尘
    2020-12-07 12:14

    This is an unfortunate behavior that appears to have been rectified in iOS 11 with the safe-area API revamp. That said, you will always get the correct value off the root view controller. For example, if you want the upper safe area height pre-iOS 11:

    Swift 4

    let root = UIApplication.shared.keyWindow!.rootViewController!
    let topLayoutGuideLength = root.topLayoutGuide.length
    

提交回复
热议问题