Canvas does not show view bounds

I would like to show view bounds in the canvas in SwiftUI view preview, But it doesn't matter if the Editor -> Canvas -> Show View Bounds option is checked:

Is this a known bug or what I'm doing wrong? 🙂

I'm using Xcode 14.2 (14C18).

  • If you're in "Live" mode (which is the default), you won't see the selection or the bounds. Tap on the "Selectable" icon and you'll see the blue box... and the light gray box if Show View Bounds is selected.

Add a Comment

Replies

I don't think bounds show in Preview, only in storyboard and maybe in static preview, not in runtime preview.

View bounds should be showing if you check "Show View Bounds", but there are some things to keep in mind:

  1. Previews will only show view bounds for views created in the file you're viewing, even if the preview is showing views across files
  2. There are some known issues with view bounds when views are located inside of certain container views. If you file a bug and attach your project we can diagnose if you're hitting one of these cases.

@kcathey this issue occurs in the preview for the currently opened file. It's a simple view from the iOS App Dev Tutorial page - Scrumdinger. You can download project files and try it.

View bounds are not shown even for simple view like bellow. I tried both modes - Selectable and Live.

import SwiftUI

struct MeetingView: View {
  var body: some View {
    VStack {
      ProgressView(value: 5, total: 15)
      HStack {
        VStack(alignment: .leading) {
          Text("Seconds Elapsed")
            .font(.caption)
          Label("300", systemImage: "hourglass.bottomhalf.filled")
        }
        Spacer()
        VStack(alignment: .trailing) {
          Text("Seconds Remaining")
            .font(.caption)
          Label("600", systemImage: "hourglass.tophalf.filled")
        }
      }
    }
    .padding()
  }
}

struct MeetingView_Previews: PreviewProvider {
  static var previews: some View {
    MeetingView()
  }
}

I will consider the creation of a bug but prefer not to do it because all my reported issues have been untouched for months and it's a waste of time for me to add another bug report then.