From 329956e993cdf949e977137acdcf227966f5e5f2 Mon Sep 17 00:00:00 2001 From: Yurim Kim Date: Tue, 22 Oct 2024 18:51:39 +0900 Subject: [PATCH] =?UTF-8?q?[Move]=20-=20Practice=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Practice/PractScrollViewController.swift | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 35-seminar/Presentation/Week2/Practice/PractScrollViewController.swift diff --git a/35-seminar/Presentation/Week2/Practice/PractScrollViewController.swift b/35-seminar/Presentation/Week2/Practice/PractScrollViewController.swift new file mode 100644 index 0000000..b486730 --- /dev/null +++ b/35-seminar/Presentation/Week2/Practice/PractScrollViewController.swift @@ -0,0 +1,74 @@ +// +// PractScrollViewController.swift +// 35-seminar +// +// Created by 김유림 on 10/15/24. +// + +import UIKit +import SnapKit + +class PractScrollViewController: UIViewController { + + // MARK: - Properties + private let scrollView = UIScrollView() + private var contentView = UIView() + private var redView = UIView() + private let yellowView = UIView() + private let greenView = UIView() + + // MARK: - Methods + override func viewDidLoad() { + super.viewDidLoad() + setUI() + setHierarchy() + setConstraints() + } + + func setUI() { + view.backgroundColor = .lightGray + redView.backgroundColor = .red + yellowView.backgroundColor = .yellow + greenView.backgroundColor = .green + } + + func setHierarchy() { + view.addSubview(scrollView) + scrollView.addSubview(contentView) + + [redView, yellowView, greenView].forEach { + contentView.addSubview($0) + } + } + + func setConstraints() { + scrollView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + + contentView.snp.makeConstraints { + $0.edges.equalToSuperview() + $0.width.equalToSuperview() + $0.height.greaterThanOrEqualToSuperview().priority(.low) + } + + redView.snp.makeConstraints { + $0.top.equalToSuperview() + $0.horizontalEdges.equalToSuperview() + $0.height.equalTo(200) + } + + yellowView.snp.makeConstraints { + $0.top.equalTo(redView.snp.bottom) + $0.horizontalEdges.equalToSuperview() + $0.height.equalTo(200) + } + + greenView.snp.makeConstraints { + $0.top.equalTo(yellowView.snp.bottom) + $0.horizontalEdges.equalToSuperview() + $0.height.equalTo(200) +// $0.bottom.equalToSuperview() + } + } +}