Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active October 5, 2019 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/ba34edb284d15d69effce9efba197e57 to your computer and use it in GitHub Desktop.
Save laevandus/ba34edb284d15d69effce9efba197e57 to your computer and use it in GitHub Desktop.
let customView = CustomView(frame: .zero) // view with intrinsicContentSize
customView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(customView)
NSLayoutConstraint.activate([
customView.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
customView.trailingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.trailingAnchor),
customView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
customView.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment