-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #18 - CountDownVC 구현 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feat/#18-\uB7EC\uB2DD\uC2DC\uC791\uC804-\uCE74\uC6B4\uD2B8\uB2E4\uC6B4-\uBDF0-UI"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // | ||
| // CountDownVC.swift | ||
| // Runnect-iOS | ||
| // | ||
| // Created by sejin on 2023/01/03. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| final class CountDownVC: UIViewController { | ||
|
|
||
| // MARK: - Properties | ||
|
|
||
| private var count = 3 | ||
|
|
||
| // MARK: - UI Components | ||
|
|
||
| private let backgroundImageView = UIImageView().then { | ||
| $0.image = ImageLiterals.imgBackground | ||
| $0.contentMode = .scaleAspectFill | ||
| } | ||
|
|
||
| private let timeLabel = UILabel().then { | ||
| $0.text = "3" | ||
| $0.font = .h6 | ||
| $0.textColor = .w1 | ||
| } | ||
|
|
||
| private let directionLabel = UILabel().then { | ||
| $0.text = "잠시 후 러닝을 시작합니다" | ||
| $0.font = .b1 | ||
| $0.textColor = .w1 | ||
| } | ||
|
|
||
| // MARK: - View Life Cycle | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| setUI() | ||
| setLayout() | ||
| animateTimeLabel() | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Methods | ||
|
|
||
| extension CountDownVC { | ||
| private func animateTimeLabel() { | ||
| self.timeLabel.transform = CGAffineTransform(scaleX: 0.4, y: 0.4) | ||
| self.timeLabel.text = "\(self.count)" | ||
| UIView.animate(withDuration: 1.0, animations: { | ||
| self.timeLabel.transform = CGAffineTransform(scaleX: 1, y: 1) | ||
| }, completion: { _ in | ||
| self.count -= 1 | ||
| if self.count > 0 { | ||
| self.animateTimeLabel() | ||
| } else { | ||
| print("Done") | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - UI & Layout | ||
|
|
||
| extension CountDownVC { | ||
| private func setUI() { | ||
| view.backgroundColor = .m1 | ||
| } | ||
|
|
||
| private func setLayout() { | ||
| view.addSubviews(backgroundImageView, timeLabel, directionLabel) | ||
|
|
||
| backgroundImageView.snp.makeConstraints { make in | ||
| make.edges.equalToSuperview() | ||
| } | ||
|
|
||
| timeLabel.snp.makeConstraints { make in | ||
| make.centerX.equalTo(view.safeAreaLayoutGuide) | ||
| make.centerY.equalTo(view.safeAreaLayoutGuide).multipliedBy(0.9) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 높이 계산할 때 multipliedBy를 쓴 이유가 몬가욥?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 중앙 정렬을 하고 중앙보다 살짝 위 또는 아래에 위치시키기 위해 multipliedBy를 사용했어요~! |
||
| } | ||
|
|
||
| directionLabel.snp.makeConstraints { make in | ||
| make.centerX.equalTo(view.safeAreaLayoutGuide) | ||
| make.centerY.equalTo(view.safeAreaLayoutGuide).multipliedBy(1.15) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,5 +71,3 @@ extension CourseDrawingHomeVC { | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옹 애니메이션.. 신기하네욥...