zoukankan      html  css  js  c++  java
  • ios 修改导航栏返回按钮的图片

    修改导航栏返回按钮的图片

    方法1

     

       [UINavigationBar appearance].backIndicatorTransitionMaskImage = [UIImage imageNamed:@"backArrowMask.png"];

        [UINavigationBar appearance].backIndicatorImage = [UIImage imageNamed:@"icon_arrowback_n”];

     

    icon_arrowback_n 大小为@2x = 42* 42

     

    方法2:

     

    UIButton * btn = [[UIButton alloc] init];

            btn.frame = CGRectMake(0, 0, 30, 44);

            UIImage * bImage = [[UIImage imageNamed: @"icon_back_bar.png"] resizableImageWithCapInsets: UIEdgeInsetsMake(0, 0, 0, 0)];

            [btn addTarget: self

                    action: @selector(backButtonClick:)

          forControlEvents: UIControlEventTouchUpInside];

            

            [btn setImage: bImage forState: UIControlStateNormal];

            UIBarButtonItem * lb = [[UIBarButtonItem alloc] initWithCustomView: btn];

            

            

            UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]

                                               

                                               initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                               

                                               target:nil action:nil];

            negativeSpacer.width = - 20;

            

            if (self.navigationController.viewControllers.count > 1) {

                self.navigationItem.leftBarButtonItems = @[negativeSpacer, lb];

            }

     

     

     

    自定义返回按钮会造成返回手势不能使用,解决方法
    ///处理自定义返回按钮后不能侧滑
    @interface RootNavigationController : UINavigationController
    
    @end
    
    
    

      

    @interface RootNavigationController : UINavigationController @end @implementation RootNavigationController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.  self.interactivePopGestureRecognizer.delegate = self; } - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if (self.childViewControllers.count == 1) { return NO; } return YES; }
  • 相关阅读:
    C#使用Json
    JQuery AJAX介绍
    封装一个自己的 Ajax小框架
    AJAX跨域实现
    AJAX 一些常用方法
    完整的 AJAX 写法(支持多浏览器)
    AJAX 简单上手
    利用反射生成SQL语句
    访问Access数据库(有多个数据库时 体现多态)
    DataTable操作(建表,建行,建列,添加数据)
  • 原文地址:https://www.cnblogs.com/qzp2014/p/5192617.html
Copyright © 2011-2022 走看看