From 6c61f44f9cb162482c8b0f5c5a0b99b9ed183880 Mon Sep 17 00:00:00 2001 From: ryuchanghwi Date: Thu, 13 Jul 2023 15:41:12 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9E=95[ADD]=20:=20SDSElevations=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/SDSKit/Color/SDS-UIColor+.swift | 9 ++ Sources/SDSKit/Elevations/SDSElevations.swift | 124 ++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 Sources/SDSKit/Elevations/SDSElevations.swift diff --git a/Sources/SDSKit/Color/SDS-UIColor+.swift b/Sources/SDSKit/Color/SDS-UIColor+.swift index 704f889..973d669 100644 --- a/Sources/SDSKit/Color/SDS-UIColor+.swift +++ b/Sources/SDSKit/Color/SDS-UIColor+.swift @@ -5,6 +5,15 @@ import UIKit public extension UIColor { + /// hex code를 이용하여 정의 + convenience init(hex: UInt, alpha: CGFloat = 1.0) { + self.init( + red: CGFloat((hex & 0xFF0000) >> 16) / 255.0, + green: CGFloat((hex & 0x00FF00) >> 8) / 255.0, + blue: CGFloat(hex & 0x0000FF) / 255.0, + alpha: CGFloat(alpha) + ) + } // gray static let gray000 = UIColor(named: "Gray000", in: .module, compatibleWith: nil)! static let gray50 = UIColor(named: "Gray50", in: .module, compatibleWith: nil)! diff --git a/Sources/SDSKit/Elevations/SDSElevations.swift b/Sources/SDSKit/Elevations/SDSElevations.swift new file mode 100644 index 0000000..1f95488 --- /dev/null +++ b/Sources/SDSKit/Elevations/SDSElevations.swift @@ -0,0 +1,124 @@ + +#if canImport(UIKit) +import UIKit +import SnapKit +#endif + +extension UIView { + public func applyBlurAndDepth2_2Shadow() { + let blurEffect = UIBlurEffect(style: .light) + let blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView.alpha = 1 + blurEffectView.frame = bounds + blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + blurEffectView.layer.cornerRadius = 20 + blurEffectView.clipsToBounds = true + addSubview(blurEffectView) + } + + public func applyDepth3_2Shadow() { + let blurEffect = UIBlurEffect(style: .light) + let blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView.alpha = 1 + blurEffectView.frame = bounds + blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + blurEffectView.layer.cornerRadius = 20 + blurEffectView.clipsToBounds = true + addSubview(blurEffectView) + } + public func applyNavigationBarShadow() { + let blurEffect = UIBlurEffect(style: .light) + let blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView.alpha = 1 + blurEffectView.frame = bounds + blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + addSubview(blurEffectView) + } +} + +extension CALayer { + public func applyDepth1Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0x0F2726).cgColor + shadowOpacity = 0.1 + shadowOffset = CGSize(width: -1, height: 1) + shadowRadius = 6 / UIScreen.main.scale + shadowPath = nil + } + + public func applyDepth2_1Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0xE9EFEF).cgColor + shadowOpacity = 0.1 + shadowOffset = CGSize(width: -3, height: 3) + shadowRadius = 6 / UIScreen.main.scale + shadowPath = nil + } + public func applyDepth2_2Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0xABBABA).cgColor + shadowOpacity = 0.2 + shadowOffset = CGSize(width: 6, height: 7) + shadowRadius = 6 / UIScreen.main.scale + let rect = bounds.insetBy(dx: -11, dy: -11) + shadowPath = UIBezierPath(rect: rect).cgPath + } + public func applyBlurAndDepth2_1Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0x4E4E4E).cgColor + shadowOpacity = 0.13 + shadowOffset = CGSize(width: 1, height: 4) + shadowRadius = 25 / UIScreen.main.scale + shadowPath = nil + } + + public func applyDepthAndDepth3_1Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0x000000).cgColor + shadowOpacity = 0.25 + shadowOffset = CGSize(width: 0, height: 0) + shadowRadius = 10 / UIScreen.main.scale + shadowPath = nil + } + + public func applyDepth4_1Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0x262626).cgColor + shadowOpacity = 0.10 + shadowOffset = CGSize(width: 2, height: 0) + shadowRadius = 3 / UIScreen.main.scale + shadowPath = nil + } + public func applyDepth4_2Shadow() { + masksToBounds = false + shadowColor = UIColor(hex: 0x262626).cgColor + shadowOpacity = 0.15 + shadowOffset = CGSize(width: 0, height: 4) + shadowRadius = 20 / UIScreen.main.scale + shadowPath = nil + } +} + +extension CALayer { + public func applySketchShadow( + color: UIColor, + alpha: Float, + x: CGFloat, + y: CGFloat, + blur: CGFloat, + spread: CGFloat + ) { + masksToBounds = false + shadowColor = color.cgColor + shadowOpacity = alpha + shadowOffset = CGSize(width: x, height: y) + shadowRadius = blur / UIScreen.main.scale + if spread == 0 { + shadowPath = nil + } else { + let rect = bounds.insetBy(dx: -spread, dy: -spread) + shadowPath = UIBezierPath(rect: rect).cgPath + } + } +} + From d37c7411d23b9940549ed2cf3d09dd5c71af19c4 Mon Sep 17 00:00:00 2001 From: ryuchanghwi Date: Thu, 13 Jul 2023 16:08:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=85[CHORE]=20:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/SDSKit/Elevations/SDSElevations.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SDSKit/Elevations/SDSElevations.swift b/Sources/SDSKit/Elevations/SDSElevations.swift index 1f95488..35891f4 100644 --- a/Sources/SDSKit/Elevations/SDSElevations.swift +++ b/Sources/SDSKit/Elevations/SDSElevations.swift @@ -16,7 +16,7 @@ extension UIView { addSubview(blurEffectView) } - public func applyDepth3_2Shadow() { + public func applyBlurAndDepth3_2Shadow() { let blurEffect = UIBlurEffect(style: .light) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.alpha = 1 @@ -72,7 +72,7 @@ extension CALayer { shadowPath = nil } - public func applyDepthAndDepth3_1Shadow() { + public func applyBlurAndDepth3_1Shadow() { masksToBounds = false shadowColor = UIColor(hex: 0x000000).cgColor shadowOpacity = 0.25 From 17246ca139b02a74e83fbd278027a35a3c9a4387 Mon Sep 17 00:00:00 2001 From: ryuchanghwi Date: Thu, 13 Jul 2023 17:41:58 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=85[CHORE]=20:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/SDSKit/Elevations/SDSElevations.swift | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Sources/SDSKit/Elevations/SDSElevations.swift b/Sources/SDSKit/Elevations/SDSElevations.swift index 35891f4..a7917dc 100644 --- a/Sources/SDSKit/Elevations/SDSElevations.swift +++ b/Sources/SDSKit/Elevations/SDSElevations.swift @@ -16,7 +16,7 @@ extension UIView { addSubview(blurEffectView) } - public func applyBlurAndDepth3_2Shadow() { + public func applyDepth3_2Shadow() { let blurEffect = UIBlurEffect(style: .light) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.alpha = 1 @@ -46,20 +46,20 @@ extension CALayer { shadowPath = nil } - public func applyDepth2_1Shadow() { + public func applyDepth2_2Shadow() { masksToBounds = false shadowColor = UIColor(hex: 0xE9EFEF).cgColor - shadowOpacity = 0.1 - shadowOffset = CGSize(width: -3, height: 3) - shadowRadius = 6 / UIScreen.main.scale + shadowOpacity = 1 + shadowOffset = CGSize(width: -3, height: -3) + shadowRadius = 10 / UIScreen.main.scale shadowPath = nil } - public func applyDepth2_2Shadow() { + public func applyDepth2_1Shadow() { masksToBounds = false shadowColor = UIColor(hex: 0xABBABA).cgColor - shadowOpacity = 0.2 + shadowOpacity = 0.12 shadowOffset = CGSize(width: 6, height: 7) - shadowRadius = 6 / UIScreen.main.scale + shadowRadius = 25 / UIScreen.main.scale let rect = bounds.insetBy(dx: -11, dy: -11) shadowPath = UIBezierPath(rect: rect).cgPath } @@ -72,7 +72,7 @@ extension CALayer { shadowPath = nil } - public func applyBlurAndDepth3_1Shadow() { + public func applyDepthAndDepth3_1Shadow() { masksToBounds = false shadowColor = UIColor(hex: 0x000000).cgColor shadowOpacity = 0.25 @@ -121,4 +121,3 @@ extension CALayer { } } } -