• LeftBarbuttonItem左滑返回&UINavigationBar透明


    一. 自定义了leftBarbuttonItem左滑返回手势失效了怎么办?

    1. CustomViewController: UIViewController, UIGestureRecognizerDelegate

    self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "back", style: .Plain, target: self, action: #selector(onBack))
    self.navigationController?.interactivePopGestureRecognizer?.delegate = self

    2. 使用FDFullscreenPopGesture 

    Use cocoapods: pod 'FDFullscreenPopGesture

    导入: import FDFullscreenPopGesture 就可以左滑返回

    禁止返回:

      To disable this pop gesture of a navigation controller:

      navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO;

      To disable this pop gesture of a view controller:

      viewController.fd_interactivePopDisabled = YES;

    如果UINavigationController's -setNavigationBarHidden:animated: method, instead, use view controller's specific API to hide its bar:

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.fd_prefersNavigationBarHidden = NO;
    }

     

    二. 怎么把我的navigationbar弄成透明的而不是带模糊的效果?

    1. 可以隐藏navigationbar

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(true, animated: true)
    }
        
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: true)
    }

    2. 设置navigationBar图片

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
    }
    
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: .Default)
        self.navigationController?.navigationBar.shadowImage = nil
    }
  • 相关阅读:
    「Codeforces 79D」Password
    「算法笔记」BSGS
    「Codeforces 468C」Hack it!
    「算法笔记」快速傅里叶变换(FFT)
    「算法笔记」2-SAT 问题
    「算法笔记」基础数论 2
    《算法笔记》二分—木棒切割问题&求凸多边形外接圆最大半径
    《算法笔记》区间贪心
    《算法笔记》PAT B1020 月饼、PAT B1023 组个最小数
    《算法笔记》n皇后问题
  • 原文地址:https://www.cnblogs.com/chrisbin/p/5404757.html
Copyright © 2020-2023  润新知