简体   繁体   中英

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"

在设置标题之前,需要将titleView设置为nil。

在您的ViewController的viewdidload中,您可以设置标题,例如

  self.title = "your title"
UIView* titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
//titleView.backgroundColor=[UIColor redColor];

self.navigationItem.titleView=titleView;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM