duan
duan

Reputation: 8845

How to display compact view in Xcode preview?

By default, Xcode would use a device's screen to show live preview. For example:

How can I enable compact mode to only display the control I'm working with ?

Upvotes: 0

Views: 227

Answers (1)

duan
duan

Reputation: 8845

Set .previewLayout(.sizeThatFits) for the view you are previewing:

struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
            .previewLayout(.sizeThatFits)
    }
}

Then you will see:

Upvotes: 1

Related Questions