码迷,mamicode.com
首页 > 其他好文 > 详细

PPRevealSideViewControllerDemo(侧滑效果)

时间:2014-10-21 15:19:05      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   sp   文件   div   

 

初始的图:

bubuko.com,布布扣

左滑,或划的效果图:

bubuko.com,布布扣

 

bubuko.com,布布扣

工程文件:

bubuko.com,布布扣

MainViewController.h

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

@end

 

MainViewContoller.m

#import "MainViewController.h"
//加入头文件
#import "PPRevealSideViewController.h"
#import "leftViewController.h"
#import "rightViewController.h"



@implementation MainViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //设置背景色
    self.view.backgroundColor= [UIColor orangeColor];
    
    //隐藏导航条
    self.navigationController.navigationBarHidden=YES;
    
    // 手势左右滑动屏幕
    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleMoveFrom:)];
    [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
    [self.view addGestureRecognizer:swipeLeft];
    
    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleMoveFrom:)];
    [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
    [self.view addGestureRecognizer:swipeRight];
  
}
// 滑动事件
-(void)handleMoveFrom:(UISwipeGestureRecognizer *)swipe
{
    if(swipe.direction == UISwipeGestureRecognizerDirectionRight){
        
        leftViewController *left = [[leftViewController alloc] init];
        [self.revealSideViewController pushViewController:left onDirection:PPRevealSideDirectionLeft withOffset:50.0 animated:YES];
    }
    if(swipe.direction == UISwipeGestureRecognizerDirectionLeft){
        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.
    
    //设置标题
    self.title=@"right";
    //设置背景色
    self.view.backgroundColor=[UIColor blueColor];
}

 

leftViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //设置标题
    self.title=@"left";
    //设置背景色
    self.view.backgroundColor=[UIColor redColor];
    
}

 

PPRevealSideViewControllerDemo(侧滑效果)

标签:style   blog   http   color   io   ar   sp   文件   div   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4040237.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!