Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ara-ta3/05c79cad5cd7efe1be9924f0bfff9abb to your computer and use it in GitHub Desktop.
Save ara-ta3/05c79cad5cd7efe1be9924f0bfff9abb to your computer and use it in GitHub Desktop.
import UIKit
import PlaygroundSupport
let width = 375
let height = 812
let view = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height))
view.backgroundColor = .brown
PlaygroundPage.current.liveView = view
PlaygroundPage.current.needsIndefiniteExecution = true
let contentView = UIView()
contentView.backgroundColor = .lightGray
contentView.translatesAutoresizingMaskIntoConstraints = false
let scrollView = UIScrollView()
scrollView.backgroundColor = .black
scrollView.addSubview(contentView)
view.addSubview(scrollView)
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
scrollView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
contentView.heightAnchor.constraint(equalToConstant: view.bounds.height * 2).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.leftAnchor.constraint(equalTo: scrollView.leftAnchor).isActive = true
contentView.rightAnchor.constraint(equalTo: scrollView.rightAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
import UIKit
import PlaygroundSupport
let width = 375
let height = 812
let view = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height))
let contentView = UIView(frame: view.bounds)
contentView.backgroundColor = .lightGray
let scrollView = UIScrollView(frame: view.bounds)
scrollView.contentSize = CGSize(width: width, height: height * 2)
scrollView.addSubview(contentView)
view.addSubview(scrollView)
PlaygroundPage.current.liveView = view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment