Created
April 30, 2024 02:37
-
-
Save takoikatakotako/0b4001f1c3fa1a88179b3f1020caaeca to your computer and use it in GitHub Desktop.
SwiftUIでPreviewを横向きにする方法です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var showingSnorlaxView = false | |
@State var showingSlowpokeView = false | |
var body: some View { | |
VStack { | |
Button(action: { | |
showingSnorlaxView = true | |
}) { | |
Text("Show Snorlax") | |
} | |
Button(action: { | |
showingSlowpokeView = true | |
}) { | |
Text("Show Slowpoke") | |
} | |
} | |
.sheet(isPresented: $showingSnorlaxView) { | |
SnorlaxView() | |
} | |
.sheet(isPresented: $showingSlowpokeView) { | |
SlowpokeView() | |
} | |
} | |
} | |
#Preview { | |
ContentView() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct SlowpokeView: View { | |
var body: some View { | |
Image(.slowpoke) | |
.resizable() | |
.frame(width: 150, height: 150) | |
.scaledToFit() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct SnorlaxView: View { | |
var body: some View { | |
Image(.snorlax) | |
.resizable() | |
.frame(width: 150, height: 150) | |
.scaledToFit() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment