let leftBarBtn = UIBarButtonItem(title: "", style: .plain, target: self,
action: #selector(backToPrevious))
leftBarBtn.image = UIImage(named: "back")
//用于消除左边空隙,要不然按钮顶不到最前面
let spacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil,
action: nil)
spacer.width = -10;
//特别注意:这里必须添加之后才能生效
self.navigationItem.leftBarButtonItems = [spacer, leftBarBtn]
网友评论