0

我正在使用 XLPagerTabStrip,我分别有一个 Scrollview 和一个 collectionView 名称 Container 和 ButtonBarView 。除 Tab item Visibility 外,一切正常。我想要像 Tabs 一样的东西来划分标签。在此处输入图像描述

Parant控制器代码是:

import UIKit
import XLPagerTabStrip

class ParentViewController: ButtonBarPagerTabStripViewController {

let purpleInspireColor = UIColor(red:0.13, green:0.03, blue:0.25, alpha:1.0)
override func viewDidLoad() {
    super.viewDidLoad()
    self.edgesForExtendedLayout = []

    // change selected bar color
    settings.style.buttonBarBackgroundColor = .white
    settings.style.buttonBarItemBackgroundColor = .white
    settings.style.selectedBarBackgroundColor = purpleInspireColor
    settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 14)
    settings.style.selectedBarHeight = 2.0
    settings.style.buttonBarMinimumLineSpacing = 0
    settings.style.buttonBarItemTitleColor = .black
    settings.style.buttonBarItemsShouldFillAvailiableWidth = true
    settings.style.buttonBarLeftContentInset = 0
    settings.style.buttonBarRightContentInset = 0
    changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
        guard changeCurrentIndex == true else { return }
        oldCell?.label.textColor = .black
        newCell?.label.textColor = self?.purpleInspireColor
    }

}


override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let included = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "IncludedViewController")
    let premium = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PremiumViewController")
    // let luxury = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LuxuryViewController")
    return [included,premium]
}
}

我有两个名为 Included 和 Premium 的选项卡。

4

1 回答 1

2

我找到了这个问题的答案

转到 Xcode 项目中的 pod 文件。将 UICollectionViewDelegate 更改为 UICollectionViewDelegateFlowLayout。

类 ButtonBarPagerTabStripViewController:PagerTabStripViewController、PagerTabStripDataSource、PagerTabStripIsProgressiveDelegate、UICollectionViewDataSource、UICollectionViewDelegateFlowLayout

于 2017-11-06T18:58:49.653 回答