I tried with frame
like for View:
@main
struct i2ElevatorApp: App {
private var portraitSize : CGSize = CGSize(width: 400, height: 600)
private var landscapeSize : CGSize = CGSize(width: 600, height: 400)
private var landscapeSize2x : CGSize = CGSize(width: 800, height: 600)
let sharedState = SharedState()
var body: some Scene {
WindowGroup {
ContentView().environmentObject(sharedState)
}.defaultSize(portraitSize)
WindowGroup(id: "SubTransformationView", for: MyData.self) { data in
if let data = data.wrappedValue {
CardView(cardIndex: data.intValue, cardType: data.stringValue)
.environmentObject(sharedState)
} else {
EmptyView()
}
}
.defaultSize(portraitSize)
.frame(width: CGFloat(400 * (sharedState.aaa.count + 1)))
But it does not work:
Value of type 'some Scene' has no member 'frame'
You can add .windowResizability(.contentSize)
to indicate WindowGroup size with its content, the default value is .automatic
.
WindowGroup(id: "SubTransformationView", for: MyData.self) { data in
if let data = data.wrappedValue {
CardView(cardIndex: data.intValue, cardType: data.stringValue)
.environmentObject(sharedState)
.frame(width: CGFloat(400 * (sharedState.aaa.count + 1))) //<- here
} else {
EmptyView()
}
}
.defaultSize(portraitSize)
//.frame(width: CGFloat(400 * (sharedState.aaa.count + 1)))
.windowResizability(.contentSize) //<- here