简体   繁体   中英

Bar Button Doesn't Appear in PageViewController

I'm learning Swift. I tried adding a button in the UIPageViewController but it didn't show when I run the application. It showed the default back button instead. I tried adding it to a UIViewController and it worked. I already added a navigational bar before inserting the BarButtonItem but it still won't show. Why is it? How do I add the button into the navigation bar of the UIPageViewController ?

Expected Navigation Menu Actual Navigation Menu
在此处输入图片说明 在此处输入图片说明

if you are pushing to pageviewcontroller then try this :-

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM