problem in Xcode playground with SwiftUI , Xcode 12.4

108 Views Asked by At

The live view shows a tiny box that just fits the text or whatever inside the view it doesn't show a full phone

here is the code

@State private var favoriteColor = "Red"
var colors = ["Red", "Green", "Blue"]

var body: some View {
    VStack{
        Picker(selection: $favoriteColor, label: Text("hey")) {
                Text("hey2")
        }
        .pickerStyle(SegmentedPickerStyle())
        Text("\(favoriteColor)")
    }
} 

here is how the live view looks

1

There are 1 best solutions below

0
jnpdx On BEST ANSWER

In your attached image, you show some code that you didn't actually include in your question. In it, you initialize a UIHostingController with a certain size, but then never do anything with it -- instead, you set the playground view to just ContentView.

You can make the ContentView appear with a larger frame by adding a frame modifier to it:

PlaygroundPage.current.setLiveView(ContentView().frame(width: 375, height: 667))