2

I'm working on rewriting an app to SwiftUI. Currently I'm struggling with what seems an easy one: Disabling the translucence in NavigationView.

The code I used before is:

UINavigationBar.appearance().isTranslucent = false

But isTranslucent is not in the autocomplete suggestions.

If I put it anyway, the app crashes inside the ViewRendererHost.render(interval:updateDisplayList:) :

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1c34016a0)

Did I miss something? How can I disable the translucence of NavigationView in SwiftUI?

Thank you for your suggestions!

Gregor
  • 75
  • 7
  • Finally I noticed that using the default displayMode "large" or "automatic" (default), the NavigationBar is not translucent by default. It only has this but when using .navigationBarTitle("Title", displayMode: .inline). Therefore for this project I will have to use the large displayMode. – Gregor Nov 20 '19 at 08:41

1 Answers1

0

This is a bug, and you will instead have to continue using UINavigationController. You can still have all your content as SwiftUI in UIHostingControllers, but you will have to keep the UIKit navigation stack or it'll explode.

Procrastin8
  • 4,193
  • 12
  • 25
  • I hope this will be fixed in future release. Meanwhile the suggestion to continue using ```UINavigationController``` is valid. Thanks – Gregor Oct 10 '19 at 05:10
  • @Gregor I have the same issue. Can you share working code? Still possible to override via App Delegate? – George Oct 11 '19 at 18:53
  • @George: No working code yet...I sent a feedback to Apple regarding this issue and I'm still waiting for an answer. – Gregor Oct 14 '19 at 09:56
  • @Gregor Thanks for the reply! Hopefully they fix, blocking from finishing my app. – George Oct 15 '19 at 18:00
  • Found a better solution, without the need of .appearance(): https://stackoverflow.com/questions/56505528/swiftui-update-navigation-bar-title-color – Gregor Dec 09 '19 at 12:38