http://www.hangge.com/blog/cache/detail_957.html
let leftBarBtn = UIBarButtonItem(title: "", style: .plain, target: self,action: #selector(backItemPressed))
leftBarBtn.image = UIImage(named: "箭头后退")
//用于消除左边空隙,要不然按钮顶不到最前面
let spacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil,action: nil)
spacer.width = -10;
self.navigationItem.leftBarButtonItems = [spacer, leftBarBtn]
func backItemPressed() {
if webView.canGoBack {
webView.goBack()
}else{
if let nav = self.navigationController {
nav.popViewController(animated: true)
}
}
}