Skip to content

Instantly share code, notes, and snippets.

@kylebshr
Created September 24, 2022 00:33
Show Gist options
  • Save kylebshr/0189796c07bbfdf4ff99f63c2eb79453 to your computer and use it in GitHub Desktop.
Save kylebshr/0189796c07bbfdf4ff99f63c2eb79453 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
let left = ScrollViewController()
let right = ScrollViewController()
override func viewDidLoad() {
super.viewDidLoad()
for child in [left, right] {
addChild(child)
view.addSubview(child.view)
child.didMove(toParent: self)
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
(left.view.frame, right.view.frame) = view.frame.divided(atDistance: view.bounds.midX, from: .minXEdge)
}
}
class ScrollViewController: UIViewController {
override func loadView() {
let scrollView = UIScrollView()
scrollView.contentSize.height = 10_000
view = scrollView
}
}
@kylebshr
Copy link
Author

kylebshr commented Sep 24, 2022

Using view controllers allows you to have two scroll views that each scroll to top based on where the status bar is tapped.

Kapture.2022-09-23.at.17.34.18.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment