4

We have an app which uses a mix of UIKit and SwiftUI. The nav hierarchy is:

UIKit Tab Bar > UIKit Table > SwiftUI View > UIKit View

as of iOS 15 the status bar is not taking on the color of the nav bar:

screenshot of app with wrong coloured status bar

I'm trying to figure out if this is something I can fix.

Looking in Reveal it looks as tho the UIHostingView has a white bg:

Screenshot of Reveal

Is it possible write code to change the bg color of the status bar in this setup?

This doesn't seem possible in a UIViewControllerRepresentable? And the hosted view is not taking up the whole screen, so changing that has no impact(?)

import SwiftUI
import PaddleCloud

struct PaddleMapView: UIViewControllerRepresentable {
    typealias UIViewControllerType = MapViewController

    var trip: Trip
    var tripSpeeds: TripSpeeds
    
    func makeUIViewController(context: Context) -> MapViewController {
        let sb = UIStoryboard(name: "Map", bundle: nil)
        let mapVC = sb.instantiateInitialViewController() as! MapViewController
        mapVC.trip = trip
        mapVC.tripSpeeds = tripSpeeds

        return mapVC
    }
    

    
}

NB: Changing the bg color in reveal does not change anything in the app.

lewis
  • 2,936
  • 2
  • 37
  • 72
  • 2
    Can you show your SwiftUI code where you are embedding the `UIViewControllerRepresentable`? Try adding `.ignoresSafeArea()` to it – aheze Sep 07 '21 at 17:19
  • I've added the code. `.ignoresSafeArea()` is a SwiftUI thing and `UIViewControllerRepresentable` is a UIKit thing. There is no `ignoresSafeArea` in UIView/UIViewController. Or am I missing something? – lewis Sep 13 '21 at 08:56
  • Yeah, try adding `.ignoresSafeArea()` to the place where you are embedding `PaddleMapView`. So for example, `PaddleMapView(trip: ..., tripSpeeds: ...).ignoresSafeArea()` – aheze Sep 13 '21 at 14:11
  • thanks @aheze, but in my case this doesn't work. the view goes under/over/instead of the tab bar, but the status bar is unaffected :( – lewis Sep 14 '21 at 13:08

0 Answers0