gpt4 book ai didi

ios - XLPagerTabStrip 不填满整个宽度

转载 作者:可可西里 更新时间:2023-11-01 00:00:05 26 4
gpt4 key购买 nike

问题

我正在开发 IOS 应用程序。我使用 XLPagerTabStrip 库来创建像在 Android 中一样的标签。 YouTube。一切正常,但我的选项卡有问题。

我有 3 个标签,但它们不会填满整个宽度,而且它们自己重叠。

3 Tabs with the Problem


父类代码

import UIKit
import XLPagerTabStrip

class InformationsParentView: ButtonBarPagerTabStripViewController {

let purpleInspireColor = UIColor(red:0.13, green:0.03, blue:0.25, alpha:1.0)

override func viewDidLoad() {

super.viewDidLoad()

settings.style.buttonBarBackgroundColor = .white
settings.style.buttonBarItemBackgroundColor = .white
settings.style.selectedBarBackgroundColor = purpleInspireColor
settings.style.buttonBarItemLeftRightMargin = 0
settings.style.selectedBarHeight = 2
settings.style.buttonBarMinimumLineSpacing = 20
settings.style.buttonBarItemTitleColor = .black
settings.style.buttonBarItemLeftRightMargin = 0
settings.style.buttonBarItemsShouldFillAvailiableWidth = true
}

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let tabWorkers = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "sbWorkers")
let tabPLs = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "sbPLs")
let tabSuperiors = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "sbSuperiors")

return [tabWorkers, tabPLs, tabSuperiors]
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}

Storyboard

Scene

场景

Scene

场景

Attributes Inspector

属性检查器

Size Inspector

尺寸检查器


信息

我找到了一个解决方案,但它对我不起作用(Github Issue 256):

settings.style.buttonBarItemsShouldFillAvailableWidth = true wouldn't fill the available width for me unless I specified settings.style.buttonBarItemLeftRightMargin = 0 as well.

有人解决这个问题吗?

我正在使用 XCode 版本 9、Swift 3 和 IOS 11。

最佳答案

打开 pod 中的 ButtonBarPagerTabStripViewController.swift 文件。

ButtonBarPagerTabStripViewController 类定义中,删除 UICollectionViewDelegate 协议(protocol)并实现 UICollectionViewDelegateFlowLayout 协议(protocol)。

所以改源码

来自

open class ButtonBarPagerTabStripViewController: 
PagerTabStripViewController, PagerTabStripDataSource,
PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate,
UICollectionViewDataSource {
...
}

open class ButtonBarPagerTabStripViewController: 
PagerTabStripViewController, PagerTabStripDataSource,
PagerTabStripIsProgressiveDelegate, UICollectionViewDataSource,
UICollectionViewDelegateFlowLayout {
...
}

当我将我的应用程序从 XCode 8.3.3 迁移到 XCode 9 时,我遇到了这个问题。这是 pod 的问题。如果您尝试使用 XCode 8.3.3,您将看不到任何错误。如果你想使用 XCode 9,请执行上述方法。

关于ios - XLPagerTabStrip 不填满整个宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46400715/

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