2017-09-16 129 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) 
} 

感謝您的幫助!

回答