From ccd997e3c6c4262d58b21753fd69b31ca0a601e1 Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Sun, 20 Mar 2022 13:05:29 +1100 Subject: Add ScrollView to details screen Would make more sense as more lines get added in (especially if ui elements programatically), as well as since horizontal layout is allowed if the screen is small you can scroll --- foray/ForayDetailViewController.swift | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/foray/ForayDetailViewController.swift b/foray/ForayDetailViewController.swift index 8d0b9ec..08845df 100644 --- a/foray/ForayDetailViewController.swift +++ b/foray/ForayDetailViewController.swift @@ -9,7 +9,12 @@ import UIKit class ForayDetailViewController: UIViewController { - let container: UIView = UIView() + let scrollView: UIScrollView = { + let sv = UIScrollView() + sv.alwaysBounceVertical = true // just for fun + return sv + }() + let container = UIView() let nameLabel: UILabel = { let l = UILabel() @@ -44,7 +49,8 @@ class ForayDetailViewController: UIViewController { } private func initialiseViews() { - self.view.addSubview(container) + self.view.addSubview(scrollView) + scrollView.addSubview(container) container.addSubview(nameLabel) container.addSubview(itemImageView) @@ -54,12 +60,16 @@ class ForayDetailViewController: UIViewController { } private func setupConstraints() { - container.snp.makeConstraints { (make) in + scrollView.snp.makeConstraints { (make) in make.edges.equalTo(self.view.snp.margins) } + container.snp.makeConstraints { (make) in + make.edges.equalToSuperview() + make.width.equalTo(scrollView.snp.width) + } nameLabel.snp.makeConstraints { (make) in - make.top.equalToSuperview().inset(8) + make.top.equalToSuperview().inset(16) make.leading.trailing.equalToSuperview().inset(8) } itemImageView.snp.makeConstraints { (make) in -- cgit