问题
我正在开发一个 IOS 应用程序。我使用 XLPagerTabStrip 库来创建像在 Android 中一样的选项卡,例如。YouTube。一切正常,但我的选项卡有问题。
我有 3 个选项卡,但它们不会填满整个宽度,而且它们会相互重叠。
父类代码
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.
}
}
故事板
场景
场景
属性检查器
尺寸检查器
信息
我找到了一个解决方案,但它对我不起作用(Github Issue 256):
settings.style.buttonBarItemsShouldFillAvailableWidth = true
除非我也指定,否则不会为我填充可用宽度settings.style.buttonBarItemLeftRightMargin = 0
。
有没有人解决这个问题?
我正在使用 XCode 版本 9、Swift 3 和 IOS 11。