반응형

🏁 학습할 내용
- layoutDirection
- 정의
- 종류
- 사용 예
- 적용
- 실제 사용
↔️ layoutDirection
✅ 정의
SwiftUI에서 컨텐츠가 그려지는 방향
➡️ ⬅️ 종류
종류는 딱 2가지다.

- leftToRight(LTR): 한국, 일본 ,미국등 우리가 아는 국가에서 쓰는 어순
- rightToLeft(RTL): 아랍어와 히브리어를 사용하는 나라가 대부분 해당
🚀 사용 예
적용


public struct Dummy: View {
@Environment(\.layoutDirection) private var layoutDirection
public var body: some View {
Text(layoutDirection == .leftToRight ? "LTR" : "RTL")
.foregroundStyle(layoutDirection == .leftToRight ? .red : .blue)
}
}
#Preview {
Dummy()
.environment(\.layoutDirection, .rightToLeft) // 파란색 RTL
}
실제 사용
출처
https://developer.apple.com/documentation/swiftui/layoutdirection
LayoutDirection | Apple Developer Documentation
A direction in which SwiftUI can lay out content.
developer.apple.com
반응형
'iOS > SwiftUI' 카테고리의 다른 글
| RedactionReasons (1) | 2025.07.27 |
|---|---|
| BlendMode (0) | 2025.07.26 |
| 스유에서 lineHeight과 letterSpacing 적용하기 (2) | 2025.07.22 |
| .contentShape (0) | 2025.07.19 |
| 커스텀 SwipePopNavigationStack 구현하기 (6) | 2025.07.13 |