【发布时间】:2016-04-08 19:34:20
【问题描述】:
我尝试向scrollView添加一个子视图(UIView)以将内容定位在scrollView中,但我对为什么可滚动内容以某个偏移量开始感到困惑。
我的视图层次结构和约束如下所示
当我运行应用程序时(滚动视图的背景为粉红色,内容视图的背景颜色为黑色)
在我的故事板中,它看起来像这样
如果这可能有帮助,在我的 viewDidAppear 方法中:
override func viewDidAppear(animated: Bool) {
print(view.frame)
print(baseView.frame)
print(scrollView.frame)
print(scrollView.bounds)
print(scrollView.contentSize)
print(contentView.frame)
}
我明白了
(0.0, 0.0, 375.0, 618.0)
(0.0, 64.0, 375.0, 554.0)
(0.0, 0.0, 375.0, 554.0)
(0.0, -64.0, 375.0, 554.0) //Why there is a negative y-offset here?
(375.0, 1200.0)
(0.0, 0.0, 375.0, 1200.0)
【问题讨论】:
标签: ios swift uiview uiscrollview