国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > iOS > 正文

iOS中抽屜效果的實(shí)例演示

2020-02-19 15:53:52
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

說(shuō)到抽屜效果,iOS中最著名的第三方類(lèi)庫(kù)是PPRevealSideViewController,當(dāng)談到第三方類(lèi)庫(kù)時(shí),我們自然會(huì)想到我們的CocoaPods,今天就讓武林技術(shù)頻道小編為大家講解一下iOS中抽屜效果的實(shí)例演示?一起跟著武林技術(shù)頻道小編的步伐來(lái)了解一下吧!

一.在工程中用CocoaPods引入第三方插件PPRevealSideViewController.

(1).在終端中搜索PPRevealSideViewController的版本

(2).在Podfile中添加相應(yīng)的版本庫(kù)

(3).之后保存一下Podfile文件,然后執(zhí)行pod install即可

二、為我們的工程添加pch文件

因?yàn)橛玫氖荴Code6, 上面默認(rèn)是沒(méi)有pch文件的,如果我們想使用pch文件,需要手動(dòng)添加,添加步驟如下

1.在XCode6中是么有pch文件的,如下圖

2.創(chuàng)建pch文件

    

3.配置pch文件

(1)、找工程的Targets->Build Settings->Apple LLVM 6.0 - Language

(2)在Prefix Header下面的Debug和Release下添加$(SRCROOT)/工程名/pch文件,入下圖

三、使用PPRevealSideViewController來(lái)實(shí)現(xiàn)抽屜效果

當(dāng)然了首先在pch文件中引入我們的第三方類(lèi)庫(kù),然后使用即可

1.在storyboard拖出來(lái)我們要用的視圖控制器,點(diǎn)擊主界面上的按鈕會(huì)以抽屜的形式展示出導(dǎo)航頁(yè),然后在導(dǎo)航頁(yè)導(dǎo)航到各個(gè)界面,之后在從各個(gè)頁(yè)面回到主界面

2.在AppDelegate中初始化我們的PPRevealSideViewController并設(shè)置為啟動(dòng)頁(yè)面代碼如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  // Override point for customization after application launch.    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    //獲取主視圖的導(dǎo)航控制器  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];    //新建PPRevealSideViewController,并設(shè)置根視圖(主頁(yè)面的導(dǎo)航視圖)  PPRevealSideViewController *sideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:vc];    sideViewController.fakeiOS7StatusBarColor = [UIColor whiteColor];    //把sideViewController設(shè)置成根視圖控制器  self.window.rootViewController = sideViewController;    [self.window makeKeyAndVisible];    return YES;}

3.在主界面使用PPRevealSideViewController來(lái)推出導(dǎo)航頁(yè)

- (IBAction)tapItem:(id)sender {    UIStoryboard *storybaord = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UITableViewController *table = [storybaord instantiateViewControllerWithIdentifier:@"CustomViewViewController"];  [self.revealSideViewController pushViewController:table onDirection:PPRevealSideDirectionLeft animated:YES];}

4.在導(dǎo)航頁(yè)點(diǎn)擊不同的按鈕使用PPRevealSideViewController跳轉(zhuǎn)到不同的controller

- (IBAction)tap1:(id)sender {   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"one"];  [self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];}- (IBAction)tap2:(id)sender {    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"two"];  [self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];  }- (IBAction)tap3:(id)sender {  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"three"];  [self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];}- (IBAction)tap4:(id)sender {  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];  UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"four"];  [self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];}

5.各個(gè)頁(yè)面返回到主界面的代碼如下:

- (IBAction)tapPage:(id)sender {  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];    UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];    [self.revealSideViewController popViewControllerWithNewCenterController:view animated:YES];}

四.到此效果實(shí)現(xiàn)完畢,下面是效果圖:

以上就是iOS中抽屜效果的實(shí)例演示的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,更多的內(nèi)容盡在武林技術(shù)頻道!

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 锦州市| 庆安县| 贺州市| 集贤县| 江都市| 白水县| 河西区| 冀州市| 仙居县| 衡阳县| 广安市| 嘉禾县| 青田县| 宣威市| 邵阳县| 墨玉县| 宜丰县| 肃南| 射阳县| 昭觉县| 交口县| 成都市| 崇信县| 吴江市| 岳阳县| 荆门市| 宜黄县| 盐城市| 鄢陵县| 福建省| 武穴市| 上虞市| 凤翔县| 南投县| 同心县| 常德市| 察隅县| 黑山县| 平潭县| 邹城市| 安多县|