Search code examples
swiftuiswiftui-form

SwiftUI sheets bolded


When I present a sheet with SwiftUI, everything gets bolded. If I swipe a bit, the bold goes away.

Example:

.navigationBarItems(leading:
    Button(action:{
      self.isSheetPresented.toggle()
    }) {
      Text("Display")
    }
    .frame(width: 25, height: 45)
    .sheet(isPresented: $isSheetPresented) {
      Textfield("Hello", text: $binding)
    })
  }

Is there an easy workaround besides applying

.fontWeight(.regular) or .font(.body) 

to everything?

PS: running Xcode Version 12.2 beta 3 (12B5035g) on MacOS 11.0 Beta (20A5395g)


Solution

  • Try to move sheet out of navigationBarItems and attach to some view inside body, like

    // ... other views
    .navigationBarItems(leading:
        Button(action:{
          self.isSheetPresented.toggle()
        }) {
          Text("Display")
        }
        .frame(width: 25, height: 45)
    )
    
    ...
    
    } // end of NavigationView
    .sheet(isPresented: $isSheetPresented) {    // << here !!
      Textfield("Hello", text: $binding)
    }