【发布时间】:2017-09-09 01:23:42
【问题描述】:
我有一个UINavigationController 的子类,称为NavController。我将其子类化的原因是因为我正在以编程方式构建 UI,对于这个特定的导航类,我需要在其导航栏的左/右部分有一个特定的按钮。
这是我在子类中的:
import UIKit
class NavController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.white
self.navigationBar.alpha = 1.0
self.navigationBar.barTintColor = UIColor.navi
self.navigationBar.isTranslucent = false
self.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
// tearing my hair out here
let refresh = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.refresh, target: self, action: #selector(doSomething))
self.navigationItem.leftBarButtonItem = refresh
}
func doSomething() {
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
从self 访问navigationItem.leftBarButtonItem 是否正确?
我的头发快用完了。
提前致谢。
【问题讨论】:
-
你可以使用。