0

我正在學習Swift。我嘗試在UIPageViewController中添加一個按鈕,但它在運行應用程序時未顯示。它顯示了默認的後退按鈕。我試圖將其添加到UIViewController,它工作。我在插入BarButtonItem之前已經添加了一個navigational bar,但它仍然不會顯示。爲什麼?如何將按鈕添加到UIPageViewController的導航欄中?欄按鈕不會出現在PageViewController中

預期的導航菜單實際導航菜單
enter image description here enter image description here

回答

0

,如果你正在推動pageviewcontroller那就試試這個: -

let myAttribute2 = [ NSForegroundColorAttributeName: UIColor.white 
,NSFontAttributeName: UIFont(name: kFontname, size: 20.0)] 
    self.navigationController?.navigationBar.isTranslucent = false 
    self.navigationController?.navigationBar.titleTextAttributes = myAttribute2 
    self.navigationController?.isNavigationBarHidden = false 
    self.navigationController?.navigationBar.barTintColor = kNavigationColor 
    let img = UIImage(named: "menu-icon") 
    let menuBtn = UIBarButtonItem(image: img, style: .plain, target: self, action: #selector(self.menuAction)) 
    self.navigationItem.leftBarButtonItem = menuBtn