ios - XLPagerTabStrip 标签没有获得相等的屏幕宽度 :Swift

标签 ios swift3 swift4 xlpagertabstrip

我正在使用 XLPagerTabStrip,我有一个 Scrollview 和一个 collectionView,名称分别为 Container 和 ButtonBarView。除了 Tab item Visibility 之外,一切正常。我想要像 Tabs 这样的东西,平均划分标签。 enter image description here

父 Controller 代码是:

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。

最佳答案

我找到了这个问题的答案

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

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

关于ios - XLPagerTabStrip 标签没有获得相等的屏幕宽度 :Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47143704/

相关文章:

swift - 核心数据谓词按今天的日期过滤

ios - searchController 过滤时的多项选择

ios - 将 UITbale View 连接到 firebase 实时数据库时出现解包错误

ios - 由于条件绑定(bind)错误的初始化程序,无法将文本 append 到字符串数组

iphone - 无法将 NSXMLParser 委托(delegate)设置为自身

ios - 使用本地通知 api 在 swift 3 中触发每周通知

ios - 无法从 Alamofire 返回获取数据

ios - 如何在 Objective-C 中将 NSString 转换为 NSMutableString?

ios - CGRect 的表达式不可分配错误

ios - Twitter是否为第三方ios应用提供社交登录选项,迅速