0

in iOS 13 apps, I used the following snippet (placed it in SceneDelegate) to set a custom back image for navigation views (SwiftUI views) which worked perfectly:

UINavigationBar.appearance().backIndicatorImage = UIImage(named: "myBackImg")
        UINavigationBar.appearance().backIndicatorTransitionMaskImage = image
        UINavigationBar.appearance().tintColor = .gray
        
        /// removing back text from back button (will affect also the text in any button in the nav bar if exists)
        UIBarButtonItem
            .appearance(whenContainedInInstancesOf: [UINavigationController.self])
            .setTitleTextAttributes([.foregroundColor: UIColor.clear], for: .normal)
        UIBarButtonItem
            .appearance(whenContainedInInstancesOf: [UINavigationController.self])
            .setTitleTextAttributes([.foregroundColor: UIColor.clear], for: .highlighted)

but unfortunately, this doesn't work with iOS 14 devices using Xcode 12.0.1 which doesn't show the custom back image.

is there any way to set a custom back image for the back button item for all SwiftUI views in the whole app at once on iOS 14 ?

JAHelia
  • 6,934
  • 17
  • 74
  • 134

0 Answers0