IOS development drawer effect implementation, ios development drawer

Source: Internet
Author: User

IOS development drawer effect implementation, ios development drawer

The famous third-party class library in iOS is PPRevealSideViewController. When it comes to third-party class libraries, we naturally think of our CocoaPods. In today's blog, we use CocoaPods to introduce PPRevealSideViewController, and then use code and storyboard in our project to make drawer effects.

1. Introduce a third-party plug-in PPRevealSideViewController with CocoaPods in the project.

(1) Search for the PPRevealSideViewController version in the terminal

 

(3) Save the Podfile file and run pod install.

 

2. Add a pch file for our project

Because XCode6 is used, there is no pch file by default. If you want to use the pch file, you need to add it manually. The steps are as follows:

1. Is there a pch file in XCode6, such

 

 

2. Create a pch File

 

3. Configure the pch File

(1) Find the target Targets-> Build Settings-> Apple LLVM 6.0-Language

 

(2) Add the $ (SRCROOT)/project name/pch file under Debug and Release under the Prefix Header

    

3. Use PPRevealSideViewController to achieve drawer Effect

Of course, first introduce our third-party class library in the pch file, and then use it.

1. drag out the View Controller we want to use on the storyboard, click the button on the main interface to display the navigation page in the form of a drawer, then navigate to each interface on the navigation page, and then return to the main interface from each page

2. initialize PPRevealSideViewController in AppDelegate and set it as the startup page. The Code is as follows:

1-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {2 // Override point for customization after application launch. 3 4 self. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]; 5 6 // obtain the navigation controller 7 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 8 UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier: @ "NavigationController"]; 9 10 // create PPRevealSideViewController, and set the Root View (home page navigation view) 11 PPRevealSideViewController * sideViewController = [[PPRevealSideViewController alloc] initWithRootViewController: vc]; 12 13 sideViewController. fakeiOS7StatusBarColor = [UIColor whiteColor]; 14 15 // set sideViewController to the Root View Controller 16 self. window. rootViewController = sideViewController; 17 18 [self. window makeKeyAndVisible]; 19 20 return YES; 21}View Code

 

3. Use PPRevealSideViewController on the main interface to launch the navigation page

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

 

4. Click different buttons on the navigation page and use PPRevealSideViewController to jump to different controllers.

1-(IBAction) tap1 :( id) sender {2 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 3 UIViewController * one = [storyboard instantiateViewControllerWithIdentifier: @ "one"]; 4 [self. revealSideViewController attributes: one animated: YES]; 5} 6 7-(IBAction) tap2 :( id) sender {8 9 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 10 UIViewController * one = [storyboard instantiateViewControllerWithIdentifier: @ "two"]; 11 [self. revealSideViewController updated: one animated: YES]; 12 13} 14 15-(IBAction) tap3 :( id) sender {16 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 17 UIViewController * one = [storyboard instantiateViewControllerWithIdentifier: @ "three"]; 18 [self. revealSideViewController attributes: one animated: YES]; 19} 20 21-(IBAction) tap4 :( id) sender {22 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 23 UIViewController * one = [storyboard instantiateViewControllerWithIdentifier: @ "four"]; 24 [self. revealSideViewController popViewControllerWithNewCenterController: one animated: YES]; 25}View Code

 

5. The Code returned from each page to the main interface is as follows:

1-(IBAction) tapPage :( id) sender {2 UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: [NSBundle mainBundle]; 3 4 UIViewController * view = [storyboard instantiateViewControllerWithIdentifier: @ "NavigationController"]; 5 6 [self. revealSideViewController popViewControllerWithNewCenterController: view animated: YES]; 7}View Code

 

4. To achieve this effect, the following is:

 

 


How to implement network protocols in ios development

Using ASIHttpRequest is much more convenient than the IOS native network. It is easy to get started and easy to use. Common interface access, post submission, queue requests, persistent connections, etc.

How can I achieve bottle drifting in ios development?

A random algorithm, with data in the background and random in the background.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.