Large overlay

It seems an overlay is limited to the size of the base view. How to remove the limit?

baseView.overlay {overlayView}

Replies

Use a ZStack instead of overlay

ZStack {
    Text("Hello, world!")
        .padding()
    Rectangle()
        .fill(.red)
}
  • I'd like to precisely lay out the base view, and overlay a bigger view nearby with alignmentGuide(). ZStack has different layout with the same alignmentGuide(), and the base view will move, so does not work in this case.

Add a Comment