SFSafariViewController status bar style

You don't have to subclass SFSafariViewController at all.

Just set modalPresentationCapturesStatusBarAppearance = true on your instance of SFSafariViewController and it will handle the rest on its own.

This works because its own default preferredStatusBarStyle is, you guessed it, .default. The view hierarchy is still relying on the presenting view controller for status bar appearance, so by setting modalPresentationCapturesStatusBarAppearance to true, it will be the receiver asked for status bar appearance.

TL;DR

safariViewController.modalPresentationCapturesStatusBarAppearance = true

(This behavior is overridden, doesn't work, when UIViewControllerBasedStatusBarAppearance is set to NO in your Info.plist)


It is not the best solution, but it works.

class MySafariViewContoller: SFSafariViewController {

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(true)

        UIApplication.sharedApplication().statusBarStyle = .Default
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillAppear(false)

        UIApplication.sharedApplication().statusBarStyle = .LightContent
    }
}

Change .Default and .LightContent as you prefer.