From b5c44af8a5dff3bc7d099b0f551754061daab129 Mon Sep 17 00:00:00 2001 From: heejoo Date: Fri, 5 Jan 2024 11:06:04 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20#4=20-=20adjusted+=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DontBe-iOS.xcodeproj/project.pbxproj | 4 ++ .../Global/Extension/adjusted+.swift | 44 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 DontBe-iOS/DontBe-iOS/Global/Extension/adjusted+.swift diff --git a/DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj b/DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj index 83fd882c..d2ee3e3d 100644 --- a/DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj +++ b/DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 2A6D54C12B479B4300F9891E /* adjusted+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A6D54C02B479B4300F9891E /* adjusted+.swift */; }; 3C2854F72B3A9E8300369C99 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2854F62B3A9E8300369C99 /* View.swift */; }; 3C2854F92B3A9E8A00369C99 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2854F82B3A9E8A00369C99 /* ViewModel.swift */; }; 3C2854FB2B3A9E9000369C99 /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2854FA2B3A9E9000369C99 /* Cell.swift */; }; @@ -29,6 +30,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 2A6D54C02B479B4300F9891E /* adjusted+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "adjusted+.swift"; sourceTree = ""; }; 3C2854F62B3A9E8300369C99 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; 3C2854F82B3A9E8A00369C99 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = ""; }; 3C2854FA2B3A9E9000369C99 /* Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = ""; }; @@ -141,6 +143,7 @@ children = ( 3C6193142B3A7A6400220CEB /* UIView+.swift */, 3C6193162B3A7A7B00220CEB /* UIStackView+.swift */, + 2A6D54C02B479B4300F9891E /* adjusted+.swift */, ); path = Extension; sourceTree = ""; @@ -307,6 +310,7 @@ 3C61930C2B3A782100220CEB /* StringLiterals.swift in Sources */, 3C2854FB2B3A9E9000369C99 /* Cell.swift in Sources */, 3C61930A2B3A781300220CEB /* ImageLiterals.swift in Sources */, + 2A6D54C12B479B4300F9891E /* adjusted+.swift in Sources */, 3C6193192B3A7AC700220CEB /* Config.swift in Sources */, 3C61931B2B3A7AD000220CEB /* NetworkError.swift in Sources */, 3C6192ED2B3A719A00220CEB /* AppDelegate.swift in Sources */, diff --git a/DontBe-iOS/DontBe-iOS/Global/Extension/adjusted+.swift b/DontBe-iOS/DontBe-iOS/Global/Extension/adjusted+.swift new file mode 100644 index 00000000..f65690f1 --- /dev/null +++ b/DontBe-iOS/DontBe-iOS/Global/Extension/adjusted+.swift @@ -0,0 +1,44 @@ +// +// adjusted+.swift +// DontBe-iOS +// +// Created by 변희주 on 1/5/24. +// + +import UIKit + +extension CGFloat { + var adjusted: CGFloat { + let ratio: CGFloat = UIScreen.main.bounds.width / 375 + return self * ratio + } + + var adjustedH: CGFloat { + let ratio: CGFloat = UIScreen.main.bounds.height / 667 + return self * ratio + } +} + +extension Int { + var adjusted: Int { + let ratio: Int = Int(UIScreen.main.bounds.width / 375) + return self * ratio + } + + var adjustedH: Int { + let ratio: Int = Int(UIScreen.main.bounds.height / 667) + return self * ratio + } +} + +extension Double { + var adjusted: Double { + let ratio: Double = Double(UIScreen.main.bounds.width / 375) + return self * ratio + } + + var adjustedH: Double { + let ratio: Double = Double(UIScreen.main.bounds.height / 667) + return self * ratio + } +}