“Swift Tambahkan Bilah Navigasi” Kode Jawaban

Swift Tambahkan Bilah Navigasi

override func viewDidLoad() {
    super.viewDidLoad()
    self.setNavigationBar()
}

func setNavigationBar() {
        let screenSize: CGRect = UIScreen.main.bounds
        let navBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: screenSize.width, height: 44))
        let navItem = UINavigationItem(title: "")
        let doneItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.done, target: nil, action: #selector(dissmissView))
        navItem.rightBarButtonItem = doneItem
        navBar.setItems([navItem], animated: false)
        self.view.addSubview(navBar)
    }

@objc
    func dissmissView(){
        self.dismiss(animated: true, completion: nil)
    }
Concerned Constrictor

Swift Tambahkan Bilah Navigasi

let navBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 44))
view.addSubview(navBar)

let navItem = UINavigationItem(title: "SomeTitle")
let doneItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(selectorName:))
navItem.rightBarButtonItem = doneItem

navBar.setItems([navItem], animated: false)
Concerned Constrictor

Jawaban yang mirip dengan “Swift Tambahkan Bilah Navigasi”

Pertanyaan yang mirip dengan “Swift Tambahkan Bilah Navigasi”

Lebih banyak jawaban terkait untuk “Swift Tambahkan Bilah Navigasi” di Swift

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya