I have a UISplitViewController with 2 custom viewControllers. When I go to setup the primary view controller and want to get the frame of the view, it gives me a totally odd value and when using it to draws the content partly off screen.
Here is my setup in storyboard
Here is the code for drawing the primary viewController
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.yellow
}
override func viewDidAppear(_ animated: Bool) {
print( "view bounds:\(view.frame)")
let testView = UIView(frame: view.frame.insetBy(dx: 30, dy: 30 ))
testView.backgroundColor = UIColor.black.withAlphaComponent(0.3)
view.addSubview( testView )
}
Here is an image of what is drawn, The two inset rects are expected to be in the bounds of the view.
Oddly enough when I go to inspect the view hierarchy it shows an odd layout for the PrimaryViewController
And here is a link to a simple test project:
Any Ideas of how to get the correct frame for the view for the primaryViewController.
Thanks
Reza


