Skip to content

Commit

Permalink
Merge pull request #14 from U-is-Ni-in-Korea/feat_13_ryu
Browse files Browse the repository at this point in the history
➕[ADD] : SDSElevations 추가
  • Loading branch information
dumpwithlove authored Jul 13, 2023
2 parents e4923ba + 17246ca commit 064544f
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/SDSKit/Color/SDS-UIColor+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down
123 changes: 123 additions & 0 deletions Sources/SDSKit/Elevations/SDSElevations.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

#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_2Shadow() {
masksToBounds = false
shadowColor = UIColor(hex: 0xE9EFEF).cgColor
shadowOpacity = 1
shadowOffset = CGSize(width: -3, height: -3)
shadowRadius = 10 / UIScreen.main.scale
shadowPath = nil
}
public func applyDepth2_1Shadow() {
masksToBounds = false
shadowColor = UIColor(hex: 0xABBABA).cgColor
shadowOpacity = 0.12
shadowOffset = CGSize(width: 6, height: 7)
shadowRadius = 25 / 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
}
}
}

0 comments on commit 064544f

Please sign in to comment.