Skip to content

Instantly share code, notes, and snippets.

@falnatsheh
Last active November 28, 2023 09:36
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save falnatsheh/4059cff797d18acc3fa89355e6a93d2c to your computer and use it in GitHub Desktop.
Save falnatsheh/4059cff797d18acc3fa89355e6a93d2c to your computer and use it in GitHub Desktop.
import UIKit
import SnapKit
class ViewController: UIViewController {
var scrollView: UIScrollView!
var stackView: UIStackView!
override func viewDidLoad() {
super.viewDidLoad()
scrollView = UIScrollView()
scrollView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scrollView)
scrollView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
stackView = UIStackView()
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
scrollView.addSubview(stackView)
stackView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
for _ in 1 ..< 100 {
let vw = UIButton(type: UIButtonType.system)
vw.setTitle("Button", for: [])
stackView.addArrangedSubview(vw)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment