【问题标题】:XLPagerTabStrip Tabs not getting equal width of screen :SwiftXLPagerTabStrip 选项卡没有获得相等的屏幕宽度:Swift
【发布时间】:2017-11-06 18:47:58
【问题描述】:

我正在使用 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 的选项卡。

【问题讨论】:

    标签: ios swift3 swift4 xlpagertabstrip


    【解决方案1】:

    我找到了这个问题的答案

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 2023-03-11
      • 2014-03-27
      • 2013-01-18
      • 1970-01-01
      相关资源
      最近更新 更多