重写导航栏左按钮

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

//
//  NextViewController.m
//  HXAandind
//
//  Created by xushuanghui on 15-3-23.
//  Copyright (c) 2015年 wxhl_zy16. All rights reserved.
//

#import "NextViewController.h"
#import "ViewController.h"

@interface NextViewController ()

@end

@implementation NextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    

    self.view.backgroundColor = [UIColor redColor];
    
    //设置返回按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 20, 50, 30);
    button.backgroundColor = [UIColor orangeColor];
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = left;
    [button setTitle:@"Backd" forState:UIControlStateNormal];
    
    //试图上添加手势
    UISwipeGestureRecognizer *swio = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swioAction)];
    swio.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swio];
}

//添加手势效果
- (void)swioAction{

    
    CATransition *caTran = [[CATransition alloc] init];
    caTran.duration = 2.0;
    caTran.delegate  = self;
    caTran.type = @"rippleEffect";
    [self.navigationController.view.layer addAnimation:caTran forKey:nil];
    [self.navigationController popToRootViewControllerAnimated:YES];

}

//添加返回按钮效果
- (void)buttonAction{

    
    
    CATransition *caTran = [[CATransition alloc] init];
    caTran.duration = 2.0;
    caTran.delegate  = self;
    caTran.type = @"rippleEffect";
    [self.navigationController.view.layer addAnimation:caTran forKey:nil];
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end