【问题标题】:Bar Button Doesn't Appear in PageViewController条形按钮未出现在 PageViewController 中
【发布时间】:2017-08-25 10:09:03
【问题描述】:

我正在学习 Swift。我尝试在UIPageViewController 中添加一个按钮,但在我运行应用程序时它没有显示。它显示了默认的后退按钮。我尝试将它添加到 UIViewController 并且它有效。在插入BarButtonItem 之前,我已经添加了navigational bar,但它仍然不会显示。为什么?如何将按钮添加到UIPageViewController的导航栏中?

预期导航菜单 实际导航菜单

【问题讨论】:

    标签: swift xcode uinavigationcontroller uinavigationbar uipageviewcontroller


    【解决方案1】:

    如果您要推送到 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
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多