導(dǎo)航控制器
UINavigation是導(dǎo)航控制器伶跷。
1:用于構(gòu)建分層應(yīng)用程序拉一,管理多個(gè)視圖的換入和換出的容器囤攀,自身提供視圖切換動(dòng)畫(huà)效果背稼。
2:他繼承自UIViewController是所有視圖控制器的基類(lèi)
3:以棧的形式呈現(xiàn)
棧--先進(jìn)后出
-入棧 puchViewController
-出棧 popViewController
-基棧
-棧頂
代碼實(shí)現(xiàn)使用Storyboard的界面
在AppDelegate.m文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//==============1===============第一種方式從storyboard中取得界面
//1.創(chuàng)建Window并設(shè)置大小
self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
//2.從項(xiàng)目目錄中獲取故事版.
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main"bundle:[NSBundle mainBundle]];
//3.根據(jù)故事版ID來(lái)獲取控制器
UIViewController *vC=[storyboard instantiateViewControllerWithIdentifier:@"vc"];
//=============2===============第二種方式不從storyboard中獲取界面
// UIViewController *vC=[[UIViewController alloc]init];
//=============================
//4.創(chuàng)建導(dǎo)航欄控制器,并設(shè)置根視圖控制器
UINavigationController *naVC=[[UINavigationController alloc]initWithRootViewController:vC];
//5.設(shè)置窗口的根視圖控制
self.window.rootViewController=naVC;
//6.把窗口腿到屏幕的最前端
[self.window makeKeyAndVisible];
return YES;
}
UIBarButtonItem
常用屬性:
leftBarButtonItem :左側(cè)按鈕
rightBarButtonItem :右側(cè)按鈕
backBarButtonItem:后退按鈕
title :標(biāo)題
titleView :標(biāo)題視圖
hidesBackButton :隱藏回退按鈕
leftBarButtonItems :左側(cè)按鈕數(shù)組
rightBarButtonItems :右側(cè)按鈕數(shù)組
常用的方法;
-(instancetype)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action; :初始化按鈕加標(biāo)題
UINavigationBar
常用屬性:
barStyle :導(dǎo)航欄風(fēng)格
topItem :最上邊的item
backItem:后退item
items :所有的item數(shù)組
tintColor :字體顏色
barTintColor :背景顏色
UIToolbar
常用屬性:
barStyle :風(fēng)格 桨嫁;
items :控件數(shù)組 植兰;
tintColor:控件顏色
barTintColor :背景顏色
模態(tài)視圖
模態(tài)視圖總是以全屏的形式實(shí)現(xiàn).
具體使用
-彈出視圖
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;
-消失視圖
-(void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;