I'm trying to implement additionalSafeAreaInsets, similar to the example from the Apples documentation, but the child view controller is not respecting the additional insets:
The expectation is that the left column view (leftView) is juxtaposed to a child view controller (childVC) within a root view controller (MyVC), but the child view controller simply takes up the entire main view.
Code Block swift import UIKit import PlaygroundSupport class MyVC: UIViewController { var leftView: UIView! let secondVC = SecondVC() override func viewDidLoad() { super.viewDidLoad() leftView = UIView(frame: CGRect(origin: .zero, size: .init(width: 50, height: self.view.bounds.size.height))) leftView.backgroundColor = .blue self.view.addSubview(leftView) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) var newSafeArea = UIEdgeInsets() if let sideViewWidth = leftView?.bounds.size.width { newSafeArea.left += sideViewWidth } print(newSafeArea) addChild(secondVC) secondVC.view.frame = self.view.safeAreaLayoutGuide.layoutFrame self.view.addSubview(secondVC.view) secondVC.didMove(toParent: self) secondVC.additionalSafeAreaInsets = newSafeArea } } class SecondVC: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = .yellow } } PlaygroundPage.current.needsIndefiniteExecution = true PlaygroundPage.current.liveView = MyVC()
The expectation is that the left column view (leftView) is juxtaposed to a child view controller (childVC) within a root view controller (MyVC), but the child view controller simply takes up the entire main view.