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