ios - 父 View 位于 subview 后面

标签 ios swift xcode xlpagertabstrip

我在我的应用程序中使用 XLPagerTabStrip 库。

https://github.com/xmartlabs/XLPagerTabStrip

这里是如何使用它的:

  import UIKit
  import XLPagerTabStrip

class MyAccountViewController: ButtonBarPagerTabStripViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    self.settings.style.buttonBarBackgroundColor = .white
    self.settings.style.buttonBarItemBackgroundColor = .white
    self.settings.style.selectedBarBackgroundColor = UIColor(red:0.52, green:0.77, blue:0.33, alpha:1.0)
    self.settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 13)
    self.settings.style.selectedBarHeight = 2.0
    self.settings.style.buttonBarMinimumLineSpacing = 10
    self.settings.style.buttonBarItemTitleColor = .black
    self.settings.style.buttonBarItemsShouldFillAvailableWidth = true
    self.settings.style.buttonBarLeftContentInset = 0
    self.settings.style.buttonBarRightContentInset = 0
    self.settings.style.selectedBarHeight = 4.0

    changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
        guard changeCurrentIndex == true else { return }
        oldCell?.label.textColor = UIColor.lightGray
        newCell?.label.textColor = .black

    }

   // navview.addBottomBorderWithColor(color: .lightGray, width: 0.5)
}

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

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "jobinfo")
    let child2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "jobedu")
    let child3 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "jobcv")
    return [child1,child2,child3]
}

} 

和 Storyboard:

enter image description here

但由于某种原因.. ScrollView 占据了整个屏幕,所有内容都在它后面,即使我设置了它的约束!

这就是我得到的:

enter image description here

一切都在 subview 后面..如何解决这个问题?

最佳答案

根据他们的指示。 “重要提示:应在调用 viewDidLoad 之前调用设置。”

override func viewDidLoad() { 
    self.settings.style.selectedBarHeight = 2
    self.settings.style.selectedBarBackgroundColor = UIColor.white
    super.viewDidLoad()
}

关于ios - 父 View 位于 subview 后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51131996/

相关文章:

ios - UITableViewCell 中每个 WebView 的 ActivityIndi​​cator

ios - 有条件地向多个 View Controller 触发 segue

swift - 按下时 NSButton 变为灰色

swift - 如何在 Swift 中实例化 AnyGenerator<T>?

c++ - 在 C++ 中从 const int 转换为 int

ios - 传递的 Segue 变量在加载后保持清除

iphone - 在 UIWebview 中重新加载 gif 图像

ios - 尝试创建一个多部分/表单数据主体,然后将其打印出来,但它给出 nil 作为输出

objective-c - 如何记录ios显示对象

ios - 如何在 SASlideMenu 中默认设置选定的第一个单元格?