gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:03:14 24 4
gpt4 key购买 nike

我正在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com