【问题标题】:Navigation Bar on Scrollview bartint not on topScrollview bartint 上的导航栏不在顶部
【发布时间】:2018-02-25 11:32:55
【问题描述】:

我正在做一个项目,我在滚动视图上有多个视图。 我可以水平滚动它们。效果很好! 但是我在添加到滚动视图的每个视图中的导航栏都有问题。 它们在上面(从屏幕截图中可以看到),但顶部的导航栏并没有从顶部填写所有内容。 有这个空白,我不想拥有。我希望这个空间与导航栏的蓝色相同。

现在我的问题是,我怎样才能做到这一点?

我将带有以下代码的视图添加到滚动视图中:

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)
}

感谢您的帮助!

【问题讨论】:

    标签: ios swift swift3 uiscrollview uinavigationbar


    【解决方案1】:

    将导航栏高度设置为 64 并将其放置在状态栏“后面”。

    Navigation Bar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2012-01-09
      • 2020-07-03
      相关资源
      最近更新 更多