Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scroll View Insets
let scrollView = UIScrollView()
scrollView.backgroundColor = .systemGreen
scrollView.contentInset = UIEdgeInsets(top: 100, left: 100, bottom: 100, right: 100)
scrollView.contentSize = self.view.bounds.size
scrollView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(scrollView)
let views = ["scrollview": scrollView]
NSLayoutConstraint.activate([
NSLayoutConstraint.constraints(withVisualFormat: "H:|[scrollview]|", metrics: nil, views: views),
NSLayoutConstraint.constraints(withVisualFormat: "V:|[scrollview]|", metrics: nil, views: views)
].flatMap({$0}))
let subview = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
subview.backgroundColor = .white
scrollView.addSubview(subview)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.