I have a view that is part of a larger view. I have a preview of that part, but XCode draws a device (some iPhone model by default) around it. I can choose a different device with .previewDevice(PreviewDevice(rawValue: "..."))
. I found a screenshot of what I want to do, so I assume it's possible somehow:
Unfortunately where I found the screenshot was not described how to do this. I tried previewDevice(.none), but that at least didn't do what I want. I'm using XCode version 14.3 Release Candidate, but can switch back version 14.2. Does anyone have an idea?
It is explained in detail here: https://sarunw.com/posts/swiftui-preview-without-device-frame/
Add .previewLayout(.sizeThatFits) in Preview_Provider
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.previewLayout(.sizeThatFits)
}
}
Then select the second left icon at the bottom of your screenshot