欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS實現(xiàn)簡單的抽屜效果

 更新時間:2016年02月26日 15:22:55   作者:青玉伏案  
這篇文章主要為大家詳細介紹了iOS實現(xiàn)簡單的抽屜效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

說到抽屜效果在iOS中比較有名的第三方類庫就是PPRevealSideViewController。一說到第三方類庫就自然而然的想到我們的CocoaPods,本文用CocoaPods引入PPRevealSideViewController,然后在我們的工程中以代碼結(jié)合storyboard來做出抽屜效果。

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

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

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

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

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

因為用的是XCode6, 上面默認是沒有pch文件的,如果我們想使用pch文件,需要手動添加,添加步驟如下

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來實現(xiàn)抽屜效果

當然了首先在pch文件中引入我們的第三方類庫,然后使用即可

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

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

- (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è)置根視圖(主頁面的導(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來推出導(dǎo)航頁

- (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)航頁點擊不同的按鈕使用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.各個頁面返回到主界面的代碼如下:

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

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

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助。

相關(guān)文章

  • iOS實現(xiàn)鎖屏頁面控制音樂播放

    iOS實現(xiàn)鎖屏頁面控制音樂播放

    這篇文章主要為大家詳細介紹了iOS實現(xiàn)鎖屏頁面控制音樂播放,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • h5 ios輸入框和鍵盤的兼容性優(yōu)化指南

    h5 ios輸入框和鍵盤的兼容性優(yōu)化指南

    這篇文章主要給大家介紹了關(guān)于h5 ios輸入框和鍵盤的兼容性優(yōu)化的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2018-11-11
  • IOS仿今日頭條滑動導(dǎo)航欄

    IOS仿今日頭條滑動導(dǎo)航欄

    今天仿今日頭條滑動導(dǎo)航和網(wǎng)易首頁導(dǎo)航封裝類優(yōu)化相似,這個也是解決手勢沖突,UIPanGestureRecognizer與ScrollView的手勢沖突
    2016-01-01
  • iOS開發(fā)中使用Quartz2D繪圖及自定義UIImageView控件

    iOS開發(fā)中使用Quartz2D繪圖及自定義UIImageView控件

    這篇文章主要介紹了iOS開發(fā)中使用Quartz2D繪圖及自定義UIImageView控件的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2015-11-11
  • iOS開發(fā)實現(xiàn)搜索框(UISearchController)

    iOS開發(fā)實現(xiàn)搜索框(UISearchController)

    這篇文章主要為大家詳細介紹了iOS開發(fā)實現(xiàn)搜索框,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • iOS實現(xiàn)爆炸的粒子效果示例代碼

    iOS實現(xiàn)爆炸的粒子效果示例代碼

    之前在網(wǎng)上看到了一個Android實現(xiàn)的爆炸效果,感覺非常不錯,所以自己嘗試用iOS來實現(xiàn)下效果,現(xiàn)在將實現(xiàn)的過程、原理以及遇到的問題分享給大家,有需要的朋友們可以參考借鑒,下面來一起看看吧。
    2016-10-10
  • iOS 實現(xiàn)簡單的加載等待動畫示例(思路與實現(xiàn))

    iOS 實現(xiàn)簡單的加載等待動畫示例(思路與實現(xiàn))

    本篇文章主要介紹了iOS 實現(xiàn)簡單的加載等待動畫示例(思路與實現(xiàn)),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • iOS實現(xiàn)視頻壓縮上傳實例代碼

    iOS實現(xiàn)視頻壓縮上傳實例代碼

    本篇文章主要介紹了iOS實現(xiàn)視頻壓縮上傳實例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • iOS微信第三方登錄實現(xiàn)

    iOS微信第三方登錄實現(xiàn)

    這篇文章主要介紹了iOS微信第三方登錄實現(xiàn)的全過程,一步一步告訴大家iOS微信實現(xiàn)第三方登錄的方法,感興趣的小伙伴們可以參考一下
    2016-01-01
  • IOS 中UIImageView響應(yīng)點擊事件

    IOS 中UIImageView響應(yīng)點擊事件

    這篇文章主要介紹了IOS 中UIImageView響應(yīng)點擊事件的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下
    2017-09-09

最新評論