topLayoutGuide in child view controller

前端 未结 11 2044
既然无缘
既然无缘 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:05

    In case if you have UIPageViewController like OP does and you have for example collection view controllers as children. Turns out the fix for content inset is simple and it works on iOS 8:

    - (void)viewWillLayoutSubviews {
        [super viewWillLayoutSubviews];
    
        UIEdgeInsets insets = self.collectionView.contentInset;
        insets.top = self.parentViewController.topLayoutGuide.length;
        self.collectionView.contentInset = insets;
        self.collectionView.scrollIndicatorInsets = insets;
    }
    

提交回复
热议问题