Skip to content

Commit

Permalink
[Move] - Practice 폴더로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
yurim830 committed Oct 22, 2024
1 parent cb3c075 commit 329956e
Showing 1 changed file with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}
}
}

0 comments on commit 329956e

Please sign in to comment.