[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 .}