1

Preface: I'm doing everything programmatically. 0 interface builder.

Previously, when pushing a VC onto a navVC stack, the pushed VC would have the upper edge occluded by the navbar. I want it so the top edge of the pushed VC is under the nav bar. I found that "edgesForExtendedLayout" did what I wanted to. Except Apple says: "Instead of this property, use the safe area of your view to determine which parts of your interface are occluded by other content. For more information, see the safeAreaLayoutGuide and safeAreaInsets properties of UIView."

I have no idea how to translate the following code:

if let nextVC = getNextVC() {
    nextVC.edgesForExtendedLayout = .init(rawValue: 0)
    pushViewController(nextVC, animated: true)
}

To use safeAreaLayoutGuide or safeAreaInsets. I can't use constraints because the pushed view is not in the view hierarchy yet?

I've attached some images to give an idea of what I'm dealing with.
Green = border of UINavigation controller

Yellow = border of 'nextVC'

Red = border of table inside 'nextVC'

With edgesForExtendedLayout set to "none" - right, but changing value Apple says not to change: It works but I shouldn't do this?

With edgesForExtendedLayout set to "all" - wrong, but default value Apple says to keep: not working

nickneedsaname
  • 731
  • 1
  • 5
  • 22

0 Answers0