2017-09-16 64 views
0

我正在开发一个项目,在滚动视图上有多个视图。 我可以水平滚动它们。它工作很好! 但我在添加到滚动视图的每个视图中的导航栏出现问题。 enter image description here 它们在上面(如您从屏幕截图中看到的那样),但顶部的导航栏没有填充顶部的所有内容。 有这个空白,我不想拥有。我希望这个空间与导航栏具有相同的蓝色。滚动视图bartint上的导航栏不在顶部

现在我的问题,我怎么能做到这一点?

我添加的意见与下面的代码来滚动视图:

class ScrollViewController: UIViewController { 

@IBOutlet weak var scrollView: UIScrollView! 
override func viewDidLoad() { 
    super.viewDidLoad() 

    let profilView = self.storyboard?.instantiateViewController(withIdentifier: "profilController") as! UIViewController 
    self.addChildViewController(profilView) 
    self.scrollView.addSubview(profilView.view) 
    profilView.didMove(toParentViewController: self) 
    profilView.view.frame = scrollView.bounds 

    let testViewTwo = self.storyboard?.instantiateViewController(withIdentifier: "chatController") as! UIViewController 
    self.addChildViewController(testViewTwo) 
    self.scrollView.addSubview(testViewTwo.view) 
    testViewTwo.didMove(toParentViewController: self) 
    testViewTwo.view.frame = scrollView.bounds 

    var frame:CGRect = testViewTwo.view.frame 
    frame.origin.x = self.view.frame.width 
    testViewTwo.view.frame = frame 

    self.scrollView.contentSize = CGSize(width: self.view.frame.width * 2, height: self.view.frame.height) 

    //startposition 
    //self.scrollView.contentOffset = CGPoint(x: (self.view.frame.width) * 1, y: self.view.frame.height) 
} 

感谢您的帮助!

回答