iOS 16 Beta Vertically Aligns Navigation Bar Title View Differently with Right Bar Items

On iOS 16, I noticed that the navigation bar title view is being aligned vertically to the top, I cannot figure out why. The odd thing is that some view controllers are fine (it's centered vertically). But some it's top aligned.

I thought maybe it had something to do with right/left bar button items, but after playing around with it - it doesn't seem to matter.

Is there some change in UIKit that is causing this?

Centered (In view controller A):

Top Aligned (In view controller B):

My component is the same in all cases where this heart graphic is - it's a subclass of UIImageView that sets the image to the heart.

Additionally. The affected view controllers are the root view controller for navigation controller, that are in a tab bar controller.

I also see this behaviour in a PHPickerViewController on iOS 16. The UISegmentedControl that shows "Photos | Albums" is aligned to the top.

In that picker, if you tap Albums then tap one of the albums, the control is replaced with a title which is correctly aligned. Go back to the start and the control is now aligned correctly.

Looks like it's just a bug in the latest beta.

@darkpaw - Yes, I see the same behavior in my app, after a push / pop, it's then aligned centered correctly. Bug! Just hope it's fixed before release so I don't have to hack this.

This is a bug where if you switch between the built in and custom title views we don't always update the layout correctly. I don't recall if there is a workaround, but this is fixed in a future build.

@Rincewind Thanks! Pointing out that the latest RC of Xcode doesn't appear to have fixed it.

Have the same problems in release version. Any thoughts of quickfix?

This is fixed for my app with iOS 16.1 (20B5045d) running on a simulated iPhone 14 Pro from Xcode 14.1 beta (14B5024h)

Try adding "navigationController?.navigationBar.layoutIfNeeded()" this after you set navigationItem.titleView 

This worked for me

For me the only way to fix this was by setting a height constraint to the custom view

myCustomView.heightAnchor.constraint(equalToConstant: .greatestFiniteMagnitude).isActive = true

iOS 16 Beta Vertically Aligns Navigation Bar Title View Differently with Right Bar Items
 
 
Q