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.

Post not yet marked as solved Up vote post of gngrwzrd Down vote post of gngrwzrd
4.3k views

Replies

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, this is still an issue with iOS 16.0 RC (20A360) running on Simulators from RC Xcode 14.0 (14A309) on iPhone 14 Pro and 14 Pro Max and iOS 16.0 RC (20A362) on an actual iPhone 11.

    If there is a workaround it would be fabulous to implement. I will also keep an eye open for a new iOS 16 beta release to see if it is fixed

  • Still not fixed

Add a Comment

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

  • I can confirm that newest version of Beta doesn't solve the problem 😩

Add a Comment

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)

  • Fixed in final version of iOS 16.1 (20B82) running on an iPhone 11

Add a Comment

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

This worked for me

  • Unfortunately, this did not fix the problem for me

Add a Comment

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

  • This workaround works for me too (iPhone 12 mini running iOS 16.0.3 (20A392)

Add a Comment