一:NavigationBar
1 粘优、設置導航欄顏色
self.navigationController.navigationBar.barTintColor= [UIColor whiteColor];
2何之、設置導航欄子視圖的顏色(例如返回按鈕顏色)
self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
3、設置導航欄背景圖片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationBar"]forBarMetrics:0];
4离斩、取消導航欄最下面的線條(必須設置背景圖片才能取消)
self.navigationController.navigationBar.shadowImage= [[UIImage alloc]init];self.navigationController.navigationBar.translucent=NO;
5、ScrollView是否可以滾動至導航欄或TabBar下面,默認為YES
self.automaticallyAdjustsScrollViewInsets=NO;
6开睡、導航欄字體大小和顏色
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:19],
NSForegroundColorAttributeName:[UIColor whiteColor]}];
7、添加多個欄按鈕項目:
UIBarButtonItem *shareItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(clickPopoverButton:)];
UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(clickPopoverButton:)];
self.navigationItem.rightBarButtonItems = @[shareItem,cameraItem];? //從右往左
8苟耻、使用圖片作為導航欄標題篇恒。設置了 titleView 后,標題自動會隱藏:
self.title=@"popover";
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"qrcode_screen"]];
9凶杖、設置左邊按鈕和back按鈕同時存在:
//在push進去的控制器里設置
self.navigationItem.leftItemsSupplementBackButton = YES;
10.設置導航欄不透明
self.navigationController.navigationBar.translucent = NO;
二:UITabBarItem
1.改變UITabBarItem 字體顏色
[[UITabBarItem appearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColorwhiteColor],UITextAttributeTextColor,nil]forState:UIControlStateNormal];
[[UITabBarItemappearance]setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorcolorWithHexString:"#00C8D3"],UITextAttributeTextColor,nil]forState:UIControlStateSelected];
2.改變UITabBarItem 字體顏色和大小
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateSelected];
3.改變UITabBarItem的選中和非選中圖片
nav1.tabBarItem.image = [ImageNamed(@"tabicon1_unselect") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
nav1.tabBarItem.selectedImage = [ImageNamed(@"tabicon1_select") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
4.改變UITabBarController的顏色
UIView*mView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,320,48)];//這是整個tabbar的顏色
[mViewsetBackgroundColor:[UIColorcolorWithPatternImage:[UIImageimageNamed:@"tabbar.png"]]];
[tab.tabBarinsertSubview:mViewatIndex:1];
mView.alpha=0.8;
5.如何隱藏系統(tǒng)自帶的tabbar
有時候有的頁面并不需要顯示tabbar胁艰,但是返回的時候要顯示tabbar,舉個例子A->B 當A push到 B 時需要設置self.navigationController.hidesBottomBarWhenPushed= YES;
同時在B頁面要
- (void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
self.tabBarController.tabBar.hidden=YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[superviewWillDisappear:animated];
self.tabBarController.tabBar.hidden=NO;
}