Here's some code:
import SwiftUI
struct RRectPlay: View {
var body: some View {
Canvas { gc, size in
gc.translateBy(x: 20.0, y: 20.0)
gc.stroke(
Path(roundedRect: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0), cornerSize: CGSize(width: 2.0, height: 2.0)),
with: .color(.black),
lineWidth: 20.0
)
}
}
}
struct RRectPlay_Previews: PreviewProvider {
static var previews: some View {
RRectPlay()
}
}
It shows a rounded rect, as requested:
If I add the fixedSize modifier to the preview:
RRectPlay().fixedSize()
The rectangle disappears:
If I add a border to see what's happened, I get this:
It seems like the definiation of "Ideal Size" ought to be something closer to the bounding box of the figure if there are no other items on the screen.
Can anyone elucidate me?