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++ 头文件与using namespace std
    cocos2dx -- 错误笔记(4)ntdll.dll堆已损坏
    大学,且行且珍惜
    cocos2dx -- 错误笔记(3)class类型重定义
    谈谈对HTML语义化的理解
    CSS深入研究:display的恐怖故事解密(2)
    We have a problem with promises
    react-组件生命周期
  • 原文地址:https://www.cnblogs.com/qzp2014/p/5192617.html
Copyright © 2011-2022 走看看