[英]How to set title of navigationitem which have titleview for some conditions
我有一個navigationItem
與titleView
。 現在在某些情況下,我想為該navigationItem
使用title
屬性。 怎么做? 任何想法?
這是我嘗試過的,但是沒有用:
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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.