ElectroBuddha ElectroBuddha - 3 years ago 97
iOS Question

NavigationBar setTitleVerticalPositionAdjustment(_:for:) method not working for title images on iOS 11 Beta

The code that works fine on iOS10 (Swift 3) not working on iOS11 Beta (Swift 4 / XCode 9.0 beta)

Setting the image as navigation bar title and adjusting its vertical position:

self.navigationItem.titleView = UIImageView(image: UIImage(named: "some_image"))

self.navigationController?.navigationBar.setTitleVerticalPositionAdjustment(-4.0, for: .default)

The image does not get adjusted vertically on iOS 11 beta, on iOS 10 it works fine.

Please note that if navigationbar title is set as text (
self.title = "Some title"
) then method
works fine. This issue is only evident when trying to use UIImageView as navigationbar title.

Has anyone experienced something similar lately?

Answer Source

It was an iOS 11 beta SDK bug.

I can confirm that the issue has been resolved in the latest iOS 11 beta 4 (15A5327g) release.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download