Wrong position of rightBarButtonItem in iOS 10

Viewed 806

I want to put the view of a UINavigationController into another view controller's view. The problem is that the right bar button is misplaced on iOS 10. On iOS 8 and 9 it looks good.

iOS 8 and 9:

enter image description here

iOS 10:

enter image description here

Here's the code how i add the navigation controller:

override func viewDidLoad() {
    super.viewDidLoad()

    let viewController = MyViewController()
    navController = UINavigationController(rootViewController: viewController)
    navController.willMove(toParentViewController: self)
    addChildViewController(navController)
    navController.view.frame = view.bounds
    view.addSubview(navController.view)
    navController.didMove(toParentViewController: self)
}

In MyViewController

override func viewDidLoad() {
    super.viewDidLoad()

    navigationItem.rightBarButtonItem = UIBarButtonItem(
        barButtonSystemItem: .done,
        target: self,
        action: #selector(doneButtonPressed)
    )
}

Also there are no clipped views (except the button itself). See snapshot of IB Debug View Hierachy:

enter image description here

Any ideas?

2 Answers
Related