隐藏系统返回按键
方法1: self.navigationItem.leftBarButtonItem = nil //隐藏自定义的item self.navigationItem.hidesBackButton = true //隐藏系统的item 方法2: let item = UIBarButtonItem(image: nil, style: UIBarButtonItem.Style.plain, target: nil, action: nil) self.navigationItem.leftBarButtonItems = [item]
设置自定义返回按钮方法:
/// 设置返回图片 func setNavBackBtn(backType:JYBackBtnTypeEnum){ var imageName = "" switch backType { case JYBackBtnTypeEnum.gray: imageName = "back_normal_gray" case JYBackBtnTypeEnum.white: imageName = "back_normal_white" } let item = UIBarButtonItem(image: UIImage.init(named: imageName)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), style: .plain, target: self, action: #selector(clcikBackBtn)) self.navigationItem.leftBarButtonItems = [item] } //返回按钮点击响应 @objc func clcikBackBtn(){ self.navigationController?.popViewController(animated: true) }