قالب وردپرس درنا توس
Home / IOS Development / ios – Cannot create SFSafariViewController status bar style lightContent

ios – Cannot create SFSafariViewController status bar style lightContent



I have a light content requirement in the status bar with a black background, but some of the screen needs a black status bar content with a white background, therefore I have kept View control-based status line appearance to YES in info.plist to adopt status bar style based on display control requirements.

My problem is when I present SFSafariViewController from any controller, it takes black status line content and white background by default ie status

I tried to override preferredStatusBarStyle in the SFSafariViewController subclass and nobody see so far.

Below is my code


  import UIKit
import SafariServices

extension SFSafariViewController {

override open was preferredStatusBarStyle: UIStatusBarStyle {
return.lightContent
}
}

extension UINavigationController {
open override was preferredStatusBarStyle: UIStatusBarStyle {
return topViewController? .preferredStatusBarStyle ?? .lightContent
}
}

class MyViewController: UIViewController, SFSafariViewControllerDelegate {

override func viewDidLoad () {
super.viewDidLoad ()
self.navigationController? .navigationBar.barTintColor = UIColor.lightGray
}

override was preferredStatusBarStyle: UIStatusBarStyle {
return.lightContent
}

@IBAction func presentSafari (sender: AnyObject) {

la safari = SFSafariViewController (URL: URL (string: "https://www.google.com/")!)
safari.delegate = self
present (safari, animated: true) {
}
}

// MARK: - SFSafariViewControllerDelegate
func safariViewControllerDidFinish (_ controller: SFSafariViewController) {
reject (animated: true, completion: null)
}
}


Source link