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