[英]How to set title of navigationitem which have titleview for some conditions
I have a navigationItem
with a titleView
. 我有一个
navigationItem
与titleView
。 Now in some conditions I want to use the title
property for that navigationItem
. 现在在某些情况下,我想为该
navigationItem
使用title
属性。 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; self.navigationItem.titleView = titleView;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.