Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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