Aaron Bratcher
Aaron Bratcher

Reputation: 6451

UIScrollView top very low

In my storyboard I have a label and a UIScrollView subclass with the scrollview constraints placing it directly under the label:

UIScrollView under label in storyboard

In code I am adding a single view that will have the content:

let contentView = UIView(frame: CGRectMake(0, 0, 2000, 1000))

override func viewDidLoad() {
    contentView.backgroundColor = UIColor.whiteColor()
    tableView.addSubview(contentView)
}

func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
    return contentView
}

When the scrollView shows, the top is not up against the label:

Simulator view, scrollView is far below label

Why isn't the scrollview up against the label?

Upvotes: 1

Views: 35

Answers (1)

Fogmeister
Fogmeister

Reputation: 77631

Add this to your view controller...

Self.automaticallyAdjustsScrollViewInsets = false

Upvotes: 2

Related Questions