我想在导航栏上方添加一个按钮,可以点击该按钮以返回到另一个视图。类似于WhatsApp 触摸以返回通话视图。 我正在跟踪代码,但它与导航栏重叠。
是否可以在导航栏上方添加按钮?如果是,该怎么办?
let button = UIButton(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height:statusBarHeight+20))
button.tag = 12323
button.setTitle("Touch to return to call", for: [])
button.setTitleColor(.white, for: [])
button.backgroundColor = .green
button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
self.navigationController?.view.addSubview(button)
self.navigationController?.view.bringSubviewToFront(button)
self.navigationController?.view.clipsToBounds = false