How to get height of topLayoutGuide?

后端 未结 3 565
太阳男子
太阳男子 2021-02-01 15:23
 moviePlayer = MPMoviePlayerController(contentURL: url)
 moviePlayer.view.frame = CGRect(x: 0, y:{layoutguide.height}, width:
 self.view.frame.width, height: 300)
 self.         


        
3条回答
  •  花落未央
    2021-02-01 15:57

    This gets the length (in points) of the portion of a view controller's view that is overlaid by translucent or transparent UIKit bars.

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        let topSpace:CGFloat
        let bottomSpace:CGFloat
        if #available(iOS 11.0, *) {
            topSpace = self.view.safeAreaInsets.top
            bottomSpace = self.view.safeAreaInsets.bottom
        } else {
            topSpace = self.topLayoutGuide.length
            bottomSpace = self.bottomLayoutGuide.length
        }
    }
    

提交回复
热议问题