Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 258
alpennec Avatar asked May 19 '26 10:05

alpennec


1 Answers

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)
}
like image 141
Asperi Avatar answered May 21 '26 22:05

Asperi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!