Skip to content

Instantly share code, notes, and snippets.

@eunjin3786
Created March 30, 2022 07:16
Show Gist options
  • Save eunjin3786/b2381d022032767af0a7537ff78885e2 to your computer and use it in GitHub Desktop.
Save eunjin3786/b2381d022032767af0a7537ff78885e2 to your computer and use it in GitHub Desktop.
import SwiftUI
struct Preview<Content: View>: View {
private let content: () -> Content
init(@ViewBuilder content: @escaping () -> Content) {
self.content = content
}
var body: some View {
Group {
content()
.environment(\.colorScheme, .light)
.previewDisplayName("라이트모드")
content()
.environment(\.colorScheme, .dark)
.previewDisplayName("다크모드")
if #available(iOS 15.0, *) {
content()
.previewInterfaceOrientation(.landscapeLeft)
.previewDisplayName("가로모드")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment