2012-07-08 71 views
1

有沒有人有關於如何在iOS中創建多行導航/頂欄的線索?我想要的東西類似於WhatsApp中的狀態行(顯示上次顯示的狀態行或當前狀態信息)。 任何意見,將不勝感激。如何創建一個類似於iOS中的WhatsApp中的多行導航欄?

我要實現類似的圖像(弗朗西斯·惠特曼/最後於[...]):

enter image description here

+1

很容易讓人們爲您解答......張貼的截圖而不是期望人們下載一些隨機應用程序。 – coneybeare 2012-07-08 17:32:34

+1

@coneybeare有時候我不知道這樣的問題是否僅僅是爲了獲取應用程序下載而進行的簡單嘗試。 – 2012-07-08 17:58:20

回答

3

默認情況下,UINavigationController將使用當前顯示的title財產在其導航欄中顯示標題的視圖控制器。你可以把它顯示任意的觀點,但是,通過設置視圖控制器的navigationItem屬性的titleView財產,像這樣:

// In your view controller’s implementation (.m) file: 
- (id)initWithNibName:(NSString *)nibName 
       bundle:(NSStirng *)nibBundle 
{ 
    self = [super initWithNibName:nibName bundle:nibBundle]; 

    if (self) { 
     UIView *myTitleView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 
                     0.0f, 
                     250.0f, 
                     44.0f)]; 
     [myView setBackgroundColor:[UIColor greenColor]]; 

     [[self navigationItem] setTitleView:myTitleView]; 
    } 

    return self; 
} 
+0

這是一個開始,非常感謝! – Maciek 2012-07-08 18:21:11

0
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width/2, 200)]; 
[label setBackgroundColor:[UIColor clearColor]]; 
[label setTextColor:[UIColor whiteColor]]; 
[label setTextAlignment:NSTextAlignmentCenter]; 
[label setNumberOfLines:0]; 
[label setText:_certificate.name]; 
self.navigationItem.titleView = label; 
相關問題