I have an iOS app in which I am setting a custom navigation title view.
It was working fine till iOS 10, but in iOS 11 the navigation title view is misplaced.
Here is the screen shot for iOS 10 -
Here is the screen shot for iOS 11 -
As you can see in the screen shots that when I run the code on iOS 10 the title view appears to be fine. But the same code on iOS 11 shifts the title view down by some pixels and it gets cut.
This is how I am setting the title view -
navigationItem.titleView = MY_CUSTOM_TITLE_VIEW
I tried many things and searched for many solutions but nothing is working.
Here's how it can be fixed -
Add this code in the custom title view class -
override var intrinsicContentSize: CGSize {
return UILayoutFittingExpandedSize
}
And the custom title view shows up at the correct position.