Created
September 24, 2022 00:33
-
-
Save kylebshr/0189796c07bbfdf4ff99f63c2eb79453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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