重写导航栏左按钮
2020年02月15日
作者:佚名
下面是来客网 jb51.cc 通过网络收集整理的代码片段。
来客网小编现在分享给大家,也给大家做个参考。
// // 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
以上是来客网(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。
以上是来客网为你收集整理的重写导航栏左按钮全部内容,希望文章能够帮你解决重写导航栏左按钮所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。