SwiftUI/Views
[SwiftUI] Form 배경색상, 시스템 색상 얻는 방법
_히처리_
2023. 8. 24. 20:43
SwiftUI의 Form의 배경색상을 얻는 방법은 다음 사이트에서 잘 설명해주고 있다.
https://sarunw.com/posts/dark-color-cheat-sheet/
Dark color cheat sheet | Sarunw
A cheat sheet that tells you what colors to use to support dark mode. This is a guide for those who want to adopt dark mode, but too lazy to figure out which color to use.
sarunw.com
나는 Form의 배경색상을 얻는 방법을 원했다.
일반 배경은 .systemBackground라는 하나의 색상이 사용된다.
하지만 Form은 그룹 색상이 있기 때문에 두 개의 색상이 사용된다.
.systemGroupedBackground가 배경 색상이 되고, .secondarySystemGroupedBackground가 그룹의 배경 색상이 된다.
SwiftUI에서는 UIColor 대신 Color를 사용하므로 Color(uiColor:)를 이용해서 다음과 같이 사용할 수 있다.
Color(uiColor: .systemGroupedBackground)