Skip to content

Commit

Permalink
[Feat] SafeArea 값 가져오기
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin0331 committed Feb 2, 2025
1 parent 62e2a9e commit 279a10e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Whidy-iOS/Core/Extension/View+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,34 @@ extension View {
modifier(RedactedModifier(isVisible: isVisible, redactedType: redactedType))
}
}

extension View {
// Safe Area의 상단 값을 가져오는 함수
func getSafeAreaTop() -> CGFloat {
return getSafeAreaInsets().top
}

// Safe Area의 하단 값을 가져오는 함수
func getSafeAreaBottom() -> CGFloat {
return getSafeAreaInsets().bottom
}

// Safe Area의 좌측 값을 가져오는 함수
func getSafeAreaLeading() -> CGFloat {
return getSafeAreaInsets().left
}

// Safe Area의 우측 값을 가져오는 함수
func getSafeAreaTrailing() -> CGFloat {
return getSafeAreaInsets().right
}

// 모든 Safe Area 값을 가져오는 함수 (UIEdgeInsets 형태로 반환)
func getSafeAreaInsets() -> UIEdgeInsets {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first else {
return .zero
}
return window.safeAreaInsets
}
}

0 comments on commit 279a10e

Please sign in to comment.