UINavigationController

知識點:編程

1)UINavigationControlleride

2)UINavigationBar動畫

3)UINavigationItemspa

4)UIToolBar圖片

======================================================get

1、UINavigationControllerit

 

一、UINavigationController介紹io

1)UINavigationController是導航控制器,它經過棧的方式控制當前顯示在屏幕上的是哪一個控制器。class

2)它能夠經過壓入(push)和彈出(pop)來改變控制器的層次。容器

3)自動提供返回(Back)按鈕,以回到上一個壓入的控制器,不須要額外編程

4)UINavigationController會提供控制器切換的動畫效果

5)   UINavgationController經過棧的形式管理多個UIViewController(即多個界面)

6)能夠管理當前在導航條(navigationBar)上的導航按鈕

7)UINavgationController爲每一個接受它管理的UIViewController自動添加UINavigationBar

8)包括四部分: 1⃣️.UINavigationController 

  2⃣️.UIViewController

    3⃣️.UINavigationBar

    4⃣️.UINavigationItem

二、導航控制器的跳轉

1)pushViewController: animated:  跳轉,切換到下一個視圖控制器(壓棧)

2)popViewControllerAnimated:  返回上一層(出棧)

3)popToRootViewControllerAnimated:  返回root視圖控制器(根視圖控制器)

4)popToViewController:  animated:  返回到指定層

5)   setViewControllers:(NSArray<UIViewController *>)animated:同時爲UINavgationController設置全部的UIViewController

=====================================================

 

2、UINavigationBar(受UINavigationController管理)

一、UINavigationBar位於屏幕頂端的控件,一般只是做爲多個UINavigationBar的容器,一樣是以棧的 形式來管理多個UINavigationItem控件

二、UINavigationBar經常使用方法和屬性

1)backgroundColor  設置導航欄的背景色,毛玻璃邊效果

2)barTintColor  設置純色背景 3)barStyle  狀態欄系統樣式(不多使用,通常咱們都會加上背景圖片)

4)setBackgroundImage: forBarMetrics: 

7.0以前,導航的高度爲44

    7.0以後,導航的高度爲64

  Metrics 指在什麼狀態下的圖片(橫32,豎64)

a)UIBarMetricsDefault 豎屏

(如下兩個方法使用以前能夠先判斷當前的版本號再決定使用哪一個)

經過該方法獲取版本號:[[[UIDevice currentDevice] systemVersion] floatValue]

b)UIBarMetricsCompact 橫屏 iOS8.0以後的方法

c)UIBarMetricsLandscapePhone iOS8.0以前的橫屏方法

5)   hidden屬性,YES爲隱藏導航欄,NO爲顯示

=========================================================

 

3、UINavigationItem

 

一、UINavigationItem經常使用方法和屬性

 

標題相關

1)title 設置導航標題

2)titleTextAttributes  設置導航欄標題的文字大小(key:NSFontAttributeName)和顏色(key:NSForegroundColorAttributeName)

3)titleView  設置標題的UIView(可使用自定義的)

按鈕相關(UIBarButtonItem)主要有右按鈕rightBarButtonItem、左按鈕leftBarButtonItem,還有多個按鈕

rightBarButtonItems:(NSArray)、leftBarButtonItems:(NSArray)

4)initWithBarButtonSystemItem: target action:  系統自帶的樣式

5)initWithCustomView:  自定義item樣式

6)initWithImage: style: target: action: 以圖片方式設置item樣式

7)initWithTitle: style: target: action: 以文字樣式設置item

8)tintColor 渲染item顏色

9)彈簧效果

  這是系統的樣式,得指定彈開的寬度:UIBarButtonSystemItemFixedSpace 

  width  設置彈開的寬度

     這是系統的樣式,會自動彈開:UIBarButtonSystemItemFlexibleSpace 

10)hidesBackButton 該屬性設置是否顯示左上角的back按鈕,YES爲隱藏

======================================================

 

4、UIToolBar

 

一、UIToolBar介紹

1)UIToolBar存在於UINavigationController控制器中

     2)UIToolBar默認顯示在UINavigationController的底部位置,且默認被隱藏

     3)當咱們須要在屏幕的底部加一些按鈕時咱們就可使用UIToolBar來設置他,不須要本身去建立UIView

     4)建立UIToolBar須要先建立一個UINavigationController控制器

 

二、UIToolBar的經常使用方法和屬性

    1)setBackgroundImage: forToolbarPosition: barmetrics:  

設置toolBar的背景圖片,UIToolBar的高度爲44

    2)setToolBarHidden:  animated:  設置toolBar的隱藏和顯示

相關文章
相關標籤/搜索