PPRevealSideViewControllerDemo (slide effect), Slide Mobile Phone

Source: Internet
Author: User

PPRevealSideViewControllerDemo (slide effect), Slide Mobile Phone

 

Initial diagram:

Slide left, or stroke:

 

Project files:

MainViewController. h

#import <UIKit/UIKit.h>@interface MainViewController : UIViewController@end

 

MainViewContoller. m

# Import "MainViewController. h "// Add the header file # import" PPRevealSideViewController. h "# import" leftViewController. h "# import" rightViewController. h "@ implementation MainViewController-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // set the background color self. view. backgroundColor = [UIColor orangeColor]; // hide the navigation bar self. navigationController. navigationBarHidden = YES; // move the screen between the left and right sides of the gesture * swipeLeft = [[using alloc] initWithTarget: self action: @ selector (handleMoveFrom :)]; [swipeLeft setDirection: callback]; [self. view addGestureRecognizer: swipeLeft]; Parameters * swipeRight = [[using alloc] initWithTarget: self action: @ selector (handleMoveFrom :)]; [swipeRight setDirection: callback]; [self. view addGestureRecognizer: swipeRight];} // sliding event-(void) handleMoveFrom :( UISwipeGestureRecognizer *) swipe {if (swipe. direction = uiswipegesturerecognizerdireright) {leftViewController * left = [[leftViewController alloc] init]; [self. revealSideViewController pushViewController: left onDirection: PPRevealSideDirectionLeft withOffset: 50.0 animated: YES];} if (swipe. direction = uiswipegesturerecognizerdireleft) {rightViewController * right = [[rightViewController alloc] init]; [self. revealSideViewController pushViewController: right onDirection: PPRevealSideDirectionRight withOffset: 50.0 animated: YES];}

 

RightViewController. m

-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // set the title self. title = @ "right"; // sets the background color self. view. backgroundColor = [UIColor blueColor];}

 

LeftViewController. m

-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // set the title self. title = @ "left"; // sets the background color self. view. backgroundColor = [UIColor redColor];}

 




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.