What I want to do is add a custom view to my UINavigationController UINavigationBar , but only for the current visible controller.
So, I create subviews of the view that I want to add as a container, and this view to the navigation bar, getting the link with:
let navBar = navigationController?.navigationBar as UINavigationBar!
The result is as follows:

However, when I click another view controller on the UINavigationController stack, this subview is saved in the UINavigationBar for the pressed viewControllers:

What is the best way to add this view only in the current UINavigationBar view and not have it stored on sequential view controllers as well?
ios objective-c iphone uikit swift
Thanos
source share