iOS笔记之UIKit_UINavigationController
? ? //設(shè)置導(dǎo)航條的樣式
? ??self.navigationController.navigationBar.barStyle?=?UIBarStyleBlackTranslucent;
? ??//默認(rèn)是白色? Bar?字體顏色黑色,如果樣式設(shè)置黑色,對應(yīng)的字體就是白色。
? ??//定義導(dǎo)航條的時候使用
? ??self.navigationController.navigationBar.translucent?=?YES;
? ??//設(shè)置導(dǎo)航條的背景顏色
? ? self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
? ??//也可以是一張圖
? ? [self.navigationController.navigationBar?setBackgroundImage:[UIImage?imageNamed:@"back.png"]?forBarMetrics:UIBarMetricsDefault];
? ??//設(shè)置裁剪屬性?44?超出的部分減掉
? ??self.navigationController.navigationBar.clipsToBounds?=?YES;
? ? //左側(cè)item
? ??? ??UIBarButtonItem?*leftButton = [[UIBarButtonItem?alloc]?initWithBarButtonSystemItem:UIBarButtonSystemItemRewind?target:self?action:@selector(barButtonClick:)];
? ??//設(shè)置唯一的標(biāo)簽
? ? leftButton.tag?= 101;
? ??//添加到導(dǎo)航條上
? ??self.navigationItem.leftBarButtonItem?= leftButton;
?? ?
? ??//添加一個右側(cè)的按鈕
? ??UIBarButtonItem?*rightButton = [[UIBarButtonItem?alloc]?initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward?target:self?action:@selector(barButtonClick:)];
? ? rightButton.tag?= 102;
? ??self.navigationItem.rightBarButtonItem?= rightButton;
? ??//設(shè)置navigationItem的標(biāo)題
? ??self.navigationItem.title?=?@"我的歌聲里";
? ??//設(shè)置副標(biāo)題
? ??self.navigationItem.prompt?=?@"曲婉婷";
?? ?
? ??//再創(chuàng)建一個UIBarButtonItem類型的按鈕
? ??UIBarButtonItem?*leftButton1 = [[UIBarButtonItem?alloc]?initWithBarButtonSystemItem:UIBarButtonSystemItemPause?target:self?action:@selector(barButtonClick:)];
? ??//設(shè)置左視圖(多個按鈕)
? ??NSArray?*leftBarButtonArray = @[leftButton,leftButton1];
? ??//把這個數(shù)組設(shè)置給自動擴(kuò)展位置?? 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?考慮內(nèi)存管理
?
?
#pragma mark -?顯示ToolBar工具條
-(void)viewWillAppear:(BOOL)animated
{
? ? [super?viewWillAppear:animated];
? ??//默認(rèn)?YES?隱藏的,NO?顯示出來的
? ??self.navigationController.toolbarHidden?=?NO;
? ??//設(shè)置工具條的樣式
? ??self.navigationController.toolbar.barStyle?=?UIBarStyleBlack;
? ??//因為iOS7系統(tǒng)默認(rèn)開啟了透明選項
? ??self.navigationController.toolbar.translucent?=?YES;
? ??//給工具條添加按鈕? 1...多個?UIBarButtonItem
? ??UIBarButtonItem?*btn1 = [[UIBarButtonItem?alloc]?initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks?target:self?action:@selector(btnClick:)];
? ? btn1.tag?= 103;
? ??//創(chuàng)建按鈕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;
?? ?
?
}
?//頁面跳轉(zhuǎn)(下一界面)
[self.navigationController?pushViewController:svc?animated:YES];
//返回上一界面
[self.navigationController?popViewControllerAnimated:YES];
轉(zhuǎn)載于:https://www.cnblogs.com/mapanguan/p/4149840.html
總結(jié)
以上是生活随笔為你收集整理的iOS笔记之UIKit_UINavigationController的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDU 5141
- 下一篇: 各个版本spring的jar包以及源码下