Simon Moshenko
Simon Moshenko

Reputation: 2156

iOS 13 UINavigationBar does not automatically calculate size when UINavigationItem changes

There is a problem when you try changing UINavigationItem (in my case it is setting searchViewController) after the view was loaded: UINavigationBar does not change it's size to fit the new content. Strangely this bug is only noticed in iOS 13, everything was fine on older versions. I have made a minimum reproducible example here https://gist.github.com/sam-moshenko/2e0310fe6e6dddace5f464e13ae3f972

Upvotes: 2

Views: 131

Answers (1)

Simon Moshenko
Simon Moshenko

Reputation: 2156

The solution is also visible in the example https://gist.github.com/sam-moshenko/2e0310fe6e6dddace5f464e13ae3f972 But it is commented out in line 8.

Solution is to manually update the UINavigationBar's size by calling sizeToFit.

Upvotes: 1

Related Questions