0

实时视图显示一个仅适合文本或视图内的任何内容的小框,它不显示完整的手机

这是代码

@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)")
    }
} 

这是实时取景的样子

4

1 回答 1

0

在您附加的图像中,您显示了一些您实际上并未包含在问题中的代码。在其中,您将 a 初始化为UIHostingController特定大小,但从不对其进行任何操作——相反,您将操场视图设置为 just ContentView

您可以通过向其添加修饰符来使其ContentView显示为更大的框架:frame

PlaygroundPage.current.setLiveView(ContentView().frame(width: 375, height: 667))
于 2021-04-09T05:07:52.413 回答