//設置導航條的樣式數組
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;工具
//默認是白色 Bar 字體顏色黑色,若是樣式設置黑色,對應的字體就是白色。字體
//定義導航條的時候使用spa
self.navigationController.navigationBar.translucent = YES;ip
//設置導航條的背景顏色內存
self.navigationController.navigationBar.backgroundColor = [UIColor redColor];get
//也能夠是一張圖it
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"back.png"] forBarMetrics:UIBarMetricsDefault];內存管理
//設置裁剪屬性 44 超出的部分減掉io
self.navigationController.navigationBar.clipsToBounds = YES;
//左側item
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(barButtonClick:)];
//設置惟一的標籤
leftButton.tag = 101;
//添加到導航條上
self.navigationItem.leftBarButtonItem = leftButton;
//添加一個右側的按鈕
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(barButtonClick:)];
rightButton.tag = 102;
self.navigationItem.rightBarButtonItem = rightButton;
//設置navigationItem的標題
self.navigationItem.title = @"個人歌聲裏";
//設置副標題
self.navigationItem.prompt = @"曲婉婷";
//再建立一個UIBarButtonItem類型的按鈕
UIBarButtonItem *leftButton1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPause target:self action:@selector(barButtonClick:)];
//設置左視圖(多個按鈕)
NSArray *leftBarButtonArray = @[leftButton,leftButton1];
//把這個數組設置給自動擴展位置 navigationItem.leftBarButtonItems 屬性
self.navigationItem.leftBarButtonItems = leftBarButtonArray;
//自定義UINavigationItem的titleView
UIView *newTilteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 44)];
newTilteView.backgroundColor = [UIColor redColor];
//添加到父視圖上
self.navigationItem.titleView = newTilteView;
//若是MRC 考慮內存管理
#pragma mark - 顯示ToolBar工具條
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//默認 YES 隱藏的,NO 顯示出來的
self.navigationController.toolbarHidden = NO;
//設置工具條的樣式
self.navigationController.toolbar.barStyle = UIBarStyleBlack;
//由於iOS7系統默認開啓了透明選項
self.navigationController.toolbar.translucent = YES;
//給工具條添加按鈕 1...多個 UIBarButtonItem
UIBarButtonItem *btn1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(btnClick:)];
btn1.tag = 103;
//建立按鈕2
UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(btnClick:)];
btn2.tag = 104;
//給btn1 彈簧 btn2
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//添加到工具條上
NSArray *toolArray = @[btn1,space,btn2];
//顯示按鈕
self.toolbarItems = toolArray;
}
//頁面跳轉(下一界面)
[self.navigationController pushViewController:svc animated:YES];
//返回上一界面
[self.navigationController popViewControllerAnimated:YES];