栏按钮不会出现在PageViewController中

时间:2017-08-25 10:09:03

标签: swift xcode uinavigationcontroller uinavigationbar uipageviewcontroller

我正在学习斯威夫特。我尝试在UIPageViewController中添加一个按钮,但在运行应用程序时没有显示。它显示了默认的后退按钮。我尝试将其添加到UIViewController并且它有效。我在插入navigational bar之前添加了BarButtonItem,但仍然无法显示。为什么?如何将按钮添加到UIPageViewController

的导航栏中

预期导航菜单 实际导航菜单
enter image description here enter image description here

1 个答案:

答案 0 :(得分: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