• 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; }
  • 相关阅读:
    English,The Da Vinci Code,Chapter 1-3
    Algorithm,Ds,Binary Indexed Trees,树状数组,二分索引树
    Algorithm,Acm,RMQ
    Algorithm,Number Theory,Prime
    Algorithm,Number Theory,GCD
    English,The Da Vinci Code
    Algorithm,LCA,Tarjan,深搜+并查集,最近公共祖先
    python,keyword arguments
    Qt,QObject
    python,build in functions
  • 原文地址:https://www.cnblogs.com/qzp2014/p/5192617.html
Copyright © 2020-2023  润新知