Skip to content

Commit 81077e9

Browse files
committed
Reafactor: extension UIViewController UiView 분리
1 parent 67a9ffb commit 81077e9

File tree

3 files changed

+46
-34
lines changed

3 files changed

+46
-34
lines changed

StopWatch.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
43228812FC89EC6FE9668022 /* Pods_StopWatch.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D5E8619A05D6284273C99B3 /* Pods_StopWatch.framework */; };
1111
DB08F0C32765DB88001EBBEE /* StopWatchDAO.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB08F0C22765DB88001EBBEE /* StopWatchDAO.swift */; };
1212
DB0E89B9262842BE00533009 /* TimeSaveModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0E89B8262842BE00533009 /* TimeSaveModalView.swift */; };
13-
DB0F172C2614310F007C8448 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0F172B2614310F007C8448 /* Utils.swift */; };
1413
DB10DB8C27E4A081000560A3 /* GodoM.ttf in Resources */ = {isa = PBXBuildFile; fileRef = DB10DB8B27E4A081000560A3 /* GodoM.ttf */; };
1514
DB1BDAED27F0603D0004AB4B /* GuideLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1BDAEC27F0603D0004AB4B /* GuideLabelView.swift */; };
1615
DB2890752623074A00FCC4BC /* ChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB2890742623074900FCC4BC /* ChartView.swift */; };
16+
DB30E09829487CFA00F1151A /* UIViewController+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB30E09729487CFA00F1151A /* UIViewController+.swift */; };
17+
DB30E09A29487D1800F1151A /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB30E09929487D1800F1151A /* UIView+.swift */; };
1718
DB340BC82940750100795FFC /* UITextField+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB340BC72940750100795FFC /* UITextField+.swift */; };
1819
DB340BCA2940753400795FFC /* UIColor+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB340BC92940753400795FFC /* UIColor+.swift */; };
1920
DB40D1F92609B32C00A4E9FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB40D1F82609B32C00A4E9FC /* AppDelegate.swift */; };
@@ -60,10 +61,11 @@
6061
A46D2DC1AD4790441A1758B2 /* Pods-StopWatch.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StopWatch.release.xcconfig"; path = "Target Support Files/Pods-StopWatch/Pods-StopWatch.release.xcconfig"; sourceTree = "<group>"; };
6162
DB08F0C22765DB88001EBBEE /* StopWatchDAO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopWatchDAO.swift; sourceTree = "<group>"; };
6263
DB0E89B8262842BE00533009 /* TimeSaveModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeSaveModalView.swift; sourceTree = "<group>"; };
63-
DB0F172B2614310F007C8448 /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
6464
DB10DB8B27E4A081000560A3 /* GodoM.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GodoM.ttf; sourceTree = "<group>"; };
6565
DB1BDAEC27F0603D0004AB4B /* GuideLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideLabelView.swift; sourceTree = "<group>"; };
6666
DB2890742623074900FCC4BC /* ChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartView.swift; sourceTree = "<group>"; };
67+
DB30E09729487CFA00F1151A /* UIViewController+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+.swift"; sourceTree = "<group>"; };
68+
DB30E09929487D1800F1151A /* UIView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+.swift"; sourceTree = "<group>"; };
6769
DB340BC72940750100795FFC /* UITextField+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+.swift"; sourceTree = "<group>"; };
6870
DB340BC92940753400795FFC /* UIColor+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+.swift"; sourceTree = "<group>"; };
6971
DB40D1F52609B32C00A4E9FC /* StopWatch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StopWatch.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -146,7 +148,6 @@
146148
isa = PBXGroup;
147149
children = (
148150
DBC67829293C9DFD0079CF1A /* extension */,
149-
DB0F172B2614310F007C8448 /* Utils.swift */,
150151
DBA7ED5627DDAF89004B0D0E /* Protocols.swift */,
151152
);
152153
path = Utils;
@@ -304,6 +305,8 @@
304305
DBC67830293F07D40079CF1A /* DateComponents+.swift */,
305306
DB340BC72940750100795FFC /* UITextField+.swift */,
306307
DB340BC92940753400795FFC /* UIColor+.swift */,
308+
DB30E09729487CFA00F1151A /* UIViewController+.swift */,
309+
DB30E09929487D1800F1151A /* UIView+.swift */,
307310
);
308311
path = extension;
309312
sourceTree = "<group>";
@@ -462,15 +465,16 @@
462465
DB8DB1882611E1C600A5814A /* ConcentrationTimeViewController.swift in Sources */,
463466
DB340BCA2940753400795FFC /* UIColor+.swift in Sources */,
464467
DBA7ED5927DDAFF4004B0D0E /* MenuOption.swift in Sources */,
468+
DB30E09A29487D1800F1151A /* UIView+.swift in Sources */,
465469
DBEC226A276864380083ECDA /* ListEditItemView.swift in Sources */,
466-
DB0F172C2614310F007C8448 /* Utils.swift in Sources */,
467470
DBA7ED6427E301C5004B0D0E /* CalendarMethod.swift in Sources */,
468471
DB40D1F92609B32C00A4E9FC /* AppDelegate.swift in Sources */,
469472
DBBFFBEF29334A3500CA3FBC /* TimeLabel.swift in Sources */,
470473
DB4FE82426BF80F100B1DF3E /* Model.swift in Sources */,
471474
DBA7ED5C27DDB790004B0D0E /* MenuOptionCell.swift in Sources */,
472475
DBEC2268276864380083ECDA /* EditTodoListView.swift in Sources */,
473476
DB74504727F6B8730088C26C /* CalendarModalView.swift in Sources */,
477+
DB30E09829487CFA00F1151A /* UIViewController+.swift in Sources */,
474478
DBA7ED5727DDAF89004B0D0E /* Protocols.swift in Sources */,
475479
);
476480
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// UIView+.swift
3+
// StopWatch
4+
//
5+
// Created by SangWoo's MacBook on 2022/12/13.
6+
//
7+
8+
import UIKit
9+
10+
extension UIView {
11+
// Timeinterval을 입력받아 시, 분, 초 튜플로 반환하는 함수.
12+
func divideSecond(timeInterval: TimeInterval) -> (String,String,String,String) {
13+
let subSecond = Int(timeInterval / 0.01)
14+
let second = subSecond / 100
15+
let minute = second / 60
16+
let result = (subSecond % 100, second % 60, minute % 60,(minute / 60) % 24)
17+
return (returnString(result.0),returnString(result.1),returnString(result.2),returnString(result.3))
18+
}
19+
20+
// 정수를 입력받아 두자리 수의 문자열로 포맷하여 반환
21+
func returnString(_ integer: Int) -> String {
22+
let formmater = NumberFormatter()
23+
formmater.minimumIntegerDigits = 2
24+
return formmater.string(from: NSNumber(value: integer))!
25+
}
26+
27+
//색상코드를 UIColor로 바꿔주는 메소드
28+
func uiColorFromHexCode(_ hex:Int)->UIColor {
29+
let red = CGFloat((hex & 0xFF0000) >> 16) / 0xFF
30+
let green = CGFloat((hex & 0x00FF00) >> 8) / 0xFF
31+
let blue = CGFloat(hex & 0x0000FF) / 0xFF
32+
33+
return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
34+
}
35+
}
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
2-
// Utils.swift
2+
// UIViewController+.swift
33
// StopWatch
44
//
5-
// Created by 신상우 on 2021/03/31.
5+
// Created by SangWoo's MacBook on 2022/12/13.
66
//
77

88
import UIKit
@@ -13,7 +13,7 @@ extension UIViewController {
1313
func hideKeyboardWhenTapped(){
1414
let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
1515
tap.cancelsTouchesInView = false // 기본값이 true이면 제스쳐 발동시 터치 이벤트가 뷰로 전달x
16-
//즉 제스쳐가 동작하면 뷰의 터치이벤트는 발생하지 않는것 false면 둘 다 작동한다는 뜻
16+
//즉 제스쳐가 동작하면 뷰의 터치이벤트는 발생하지 않는것 false면 둘 다 작동한다는 뜻
1717
self.view.addGestureRecognizer(tap) //view에 제스쳐추가
1818
}
1919

@@ -40,30 +40,3 @@ extension UIViewController {
4040
present(alert, animated: true)
4141
}
4242
}
43-
44-
extension UIView {
45-
// Timeinterval을 입력받아 시, 분, 초 튜플로 반환하는 함수.
46-
func divideSecond(timeInterval: TimeInterval) -> (String,String,String,String) {
47-
let subSecond = Int(timeInterval / 0.01)
48-
let second = subSecond / 100
49-
let minute = second / 60
50-
let result = (subSecond % 100, second % 60, minute % 60,(minute / 60) % 24)
51-
return (returnString(result.0),returnString(result.1),returnString(result.2),returnString(result.3))
52-
}
53-
54-
// 정수를 입력받아 두자리 수의 문자열로 포맷하여 반환
55-
func returnString(_ integer: Int) -> String {
56-
let formmater = NumberFormatter()
57-
formmater.minimumIntegerDigits = 2
58-
return formmater.string(from: NSNumber(value: integer))!
59-
}
60-
61-
//색상코드를 UIColor로 바꿔주는 메소드
62-
func uiColorFromHexCode(_ hex:Int)->UIColor {
63-
let red = CGFloat((hex & 0xFF0000) >> 16) / 0xFF
64-
let green = CGFloat((hex & 0x00FF00) >> 8) / 0xFF
65-
let blue = CGFloat(hex & 0x0000FF) / 0xFF
66-
67-
return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
68-
}
69-
}

0 commit comments

Comments
 (0)