首页 > 解决方案 > 寻呼机选项卡隐藏在 ios swift 中 XLPagerTabStrip 的导航栏下。(使用 XLPagerTabStrip)

问题描述

我在 swift 4 应用程序中使用XLPagerTabStrip ,我使用collectionview并且一切正常,但按钮栏隐藏在导航栏后面。

我搜索了这个问题。所以我得到了这个链接和答案

XLPagerTabStrip ButtonBar 粘在导航栏后面

我编辑这个。我将collectionview 类设置为“ButtonBarView”。图片的链接是这个

图片链接:https ://i.stack.imgur.com/WjARH.png

然后将其插座与左侧面板中的视图连接

图片链接:https ://i.stack.imgur.com/uyFBr.png

但这对我不起作用。我搜索了另一个网站和问题。

链接:https ://github.com/xmartlabs/XLPagerTabStrip/issues/262

我用这个编辑我的代码。后

 ViewDidLoad

添加以下代码

self.view.layoutIfNeeded()
buttonBarView.selectedBar.frame.origin.y = buttonBarView.frame.size.height - settings.style.selectedBarHeight

但它没有用。我的代码是

class medicationViewController: ButtonBarPagerTabStripViewController {

override func viewDidLoad() {
self.loaDesign()
super.viewDidLoad()
self.view.layoutIfNeeded()
buttonBarView.selectedBar.frame.origin.y = buttonBarView.frame.size.height - settings.style.selectedBarHeight
    }

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {

    let child_1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "apercuViewController")
    let child_2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "nouveauViewController")
    let child_3 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "prescripViewController")
    let child_4 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "schemaViewController")

    return [child_1,child_2,child_3,child_4]

}

 func loaDesign() {
    // change selected bar color

    self.settings.style.selectedBarHeight = 2.0
    self.settings.style.selectedBarBackgroundColor =  UIColor(red: 0/255, green: 162/255, blue: 255/255, alpha: 1.0)
    self.settings.style.buttonBarBackgroundColor = UIColor.white
    self.settings.style.buttonBarItemBackgroundColor = UIColor.white
    self.settings.style.buttonBarItemFont = UIFont(name: "Poppins", size: 14)!
    self.settings.style.buttonBarItemTitleColor = .white

    self.settings.style.buttonBarMinimumLineSpacing = 0
    self.settings.style.buttonBarItemsShouldFillAvailiableWidth = true
    self.settings.style.buttonBarLeftContentInset = 0
    self.settings.style.buttonBarRightContentInset = 0

    changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in

        guard changeCurrentIndex == true else { return }
        oldCell?.label.textColor = UIColor.black
        newCell?.label.textColor =  UIColor(red: 0/255, green: 162/255, blue: 255/255, alpha: 1.0)
    }
}

在子视图控制器中我的代码是

 extension apercuViewController : IndicatorInfoProvider{

func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
    return IndicatorInfo(title: "APERCU")
   }
 }

我想添加所有这些的图像,但他们不允许我。这里需要在集合视图下获取容器视图吗?我没有采取容器视图。

标签: iosswift

解决方案


推荐阅读