【发布时间】:2017-02-02 12:14:28
【问题描述】:
我需要动态创建Navigation Bar并在左侧设置Cancel按钮。
有代码我如何尝试这样做
var navBar: UINavigationBar = UINavigationBar()
func setNavBarToTheView() {
navBar.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 80.0)
navBar.backgroundColor = (UIColor.black)
let navTitle = UINavigationItem(title: "Camera")
let navCancel = UINavigationItem(title: "Cancel")
navBar.setItems([navCancel, navTitle], animated: true)
view.addSubview(navBar)
}
但是我怎样才能将动作监听器添加到Cancel 按钮??
【问题讨论】:
标签: swift xcode navigation navigationbar