1. 程式人生 > >self.navigationbar的設置總匯

self.navigationbar的設置總匯

con ews normal self. pop dex tab set uifont

//隱藏與顯示

self.navigationController.navigationBar.hidden = YES;

self.navigationController.navigationBarHidden = YES;//這個設置沒有側滑的動畫

//navigationBar的透明問題

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];//給navigationBar設置一個空的背景圖片即可實現透明,而且標題按鈕都在

self.navigationController.navigationBar.shadowImage = [UIImage new];
//其實這個線也是image控制的。設為空即可

//navigationBar是一個復合視圖,它是有許多個控件組成的,那麽我們就可以從他的內部入手
[[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 0;//這裏可以根據scrollView的偏移量來設置alpha就實現了漸變透明的效果

//3、全局設置navigationBar標題的樣式和barItem的標題樣式

//UIColorWithHexRGB( )這個方法是自己定義的,這裏只需要給個顏色就好了
[[UINavigationBar appearance] setBarTintColor:UIColorWithHexRGB(0xfefefe)];

[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:UIColorWithHexRGB(0xfe6d27)}];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:10],NSForegroundColorAttributeName : UIColorWithHexRGB(0x666666)} forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSiz

//5、側滑手勢返回

if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
//需要遵循一下手勢的代理 self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;

//問題:當返回navigationController的最頂層的Controller的時候。再次側滑,這個時候你在點擊一個push頁面的操作,你會發現卡那了,半天才會有反應。
這是由於,在最頂層Controller手勢依然有效,但是滑動後,並找不到返回的頁面。造成軟件卡頓,假死所以就要在rootViewController中讓此手勢失效。把下面的設為NO

self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}

self.navigationbar的設置總匯