[Reading Notes] Slide effect, Reading Notes slide

Source: Internet
Author: User

[Reading Notes] Slide effect, Reading Notes slide

I ,.

2. Engineering Drawing.

3. Code.

AppDelegate. h

# Import <UIKit/UIKit. h> // Add the header file # import "PPRevealSideViewController. h "@ interface AppDelegate: UIResponder <UIApplicationDelegate, PPRevealSideViewControllerDelegate> @ property (strong, nonatomic) UIWindow * window; @ end

 

AppDelegate. m

#import "AppDelegate.h"#import "MainViewController.h"@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    // Override point for customization after application launch.        MainViewController *main = [[MainViewController alloc] init];    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main];    PPRevealSideViewController *revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];    revealSideViewController.delegate = self;    self.window.rootViewController = revealSideViewController;        self.window.backgroundColor = [UIColor whiteColor];    [self.window makeKeyAndVisible];    return YES;}

 

MainViewController. h

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

 

MainViewController. m

# Import "MainViewController. h "// Add the header file # import" PPRevealSideViewController. h "# import" leftViewController. h "# import" rightViewController. h "@ interface MainViewController () @ end @ implementation MainViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(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] ;}}-(void) Authorization {[super ready]; // Dispose of any resources that can be recreated .}

 

RightViewController. h

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

 

RightViewController. m

# Import "rightViewController. h "@ interface rightViewController () @ end @ implementation rightViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(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];}-(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .}

 

LeftViewController. h

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

 

LeftViewController. m

# Import "leftViewController. h "@ interface leftViewController () @ end @ implementation leftViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(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];}-(void) didReceiveMemoryWarning {[super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated .}

 

 

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.