Search code examples
iosswiftuinavigationbarswrevealviewcontroller

How to set title of navigationitem which have titleview for some conditions


I have a navigationItem with a titleView. Now in some conditions I want to use the title property for that navigationItem. How to do that? Any idea?

Here is what I have tried, however is not working:

self.revealViewController().navigationItem.titleView = UIView.init()

self.revealViewController().navigationItem.title = "My Item"

Solution

  • Before you set title, you need to set titleView to nil.