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; }
  • 相关阅读:
    SQL 查询中 not in的改进,--not exists
    REST接口--转摘
    C#中@的用法总结(转)
    有感于哈工大matlab被限制使用
    Oracle CURRVAL应用限制
    oracle to_char()函数--数字型到字符型
    如何提交代码到git仓库
    cannot find module 'xxx' 解决办法
    DOM-基本概念及使用
    AJAX-同源策略 跨域访问
  • 原文地址:https://www.cnblogs.com/qzp2014/p/5192617.html
Copyright © 2011-2022 走看看