設置NavigationBar和UITabBarItem的屬性

一: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;

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市腾么,隨后出現(xiàn)的幾起案子奈梳,更是在濱河造成了極大的恐慌,老刑警劉巖解虱,帶你破解...
    沈念sama閱讀 222,590評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件攘须,死亡現(xiàn)場離奇詭異,居然都是意外死亡殴泰,警方通過查閱死者的電腦和手機于宙,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來悍汛,“玉大人捞魁,你說我怎么就攤上這事±敫溃” “怎么了谱俭?”我有些...
    開封第一講書人閱讀 169,301評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長健霹。 經(jīng)常有香客問我旺上,道長,這世上最難降的妖魔是什么糖埋? 我笑而不...
    開封第一講書人閱讀 60,078評論 1 300
  • 正文 為了忘掉前任宣吱,我火速辦了婚禮,結果婚禮上瞳别,老公的妹妹穿的比我還像新娘征候。我一直安慰自己,他們只是感情好祟敛,可當我...
    茶點故事閱讀 69,082評論 6 398
  • 文/花漫 我一把揭開白布疤坝。 她就那樣靜靜地躺著,像睡著了一般馆铁。 火紅的嫁衣襯著肌膚如雪跑揉。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,682評論 1 312
  • 那天埠巨,我揣著相機與錄音历谍,去河邊找鬼。 笑死辣垒,一個胖子當著我的面吹牛望侈,可吹牛的內容都是我干的。 我是一名探鬼主播勋桶,決...
    沈念sama閱讀 41,155評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼脱衙,長吁一口氣:“原來是場噩夢啊……” “哼侥猬!你這毒婦竟也來了?” 一聲冷哼從身側響起捐韩,我...
    開封第一講書人閱讀 40,098評論 0 277
  • 序言:老撾萬榮一對情侶失蹤退唠,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后荤胁,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體铜邮,經(jīng)...
    沈念sama閱讀 46,638評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,701評論 3 342
  • 正文 我和宋清朗相戀三年寨蹋,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片扔茅。...
    茶點故事閱讀 40,852評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡已旧,死狀恐怖,靈堂內的尸體忽然破棺而出召娜,到底是詐尸還是另有隱情运褪,我是刑警寧澤,帶...
    沈念sama閱讀 36,520評論 5 351
  • 正文 年R本政府宣布玖瘸,位于F島的核電站秸讹,受9級特大地震影響,放射性物質發(fā)生泄漏雅倒。R本人自食惡果不足惜璃诀,卻給世界環(huán)境...
    茶點故事閱讀 42,181評論 3 335
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望蔑匣。 院中可真熱鬧劣欢,春花似錦、人聲如沸裁良。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽价脾。三九已至牧抵,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間侨把,已是汗流浹背犀变。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留座硕,地道東北人弛作。 一個月前我還...
    沈念sama閱讀 49,279評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像华匾,于是被迫代替她去往敵國和親映琳。 傳聞我的和親對象是個殘疾皇子机隙,可洞房花燭夜當晚...
    茶點故事閱讀 45,851評論 2 361

推薦閱讀更多精彩內容