Custom titleView navigation is no longer displayed only on iOS 11

I have a custom view as a search bar and set it to Navigation titleView. CustomView is no longer displayed on iOS 11 devices. I was debugging using the Hierarchy View, and I found that the size of the custom view frame (0,0).

This problem only occurs on iOS 11, it works fine on iOS 9 and 10.

UIView *searchBarView = [self createSearchBarView];  // Custom searchBarView
self.navigationItem.titleView = searchBarView;
searchBarView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

How to add custom view as Navigation titleView on iOS 11?

+4
source share
1 answer

In your custom UIViewoverreire style below

override var intrinsicContentSize: CGSize {
   return UILayoutFittingExpandedSize
} 

Check and let me know if this works for you or not?

+3
source

Source: https://habr.com/ru/post/1687430/


All Articles