As you can see this only happened in iOS 12.
iOS 12 iOS 11
here is my code:
import UIKit
import WebKit
class ViewController: UIViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override var prefersStatusBarHidden: Bool {
return false
}
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
webView = WKWebView(frame: UIScreen.main.bounds)
view.addSubview(webView)
webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
webView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
webView.loadHTMLString("<p><iframe src=\"https://www.youtube.com/embed/HCjNJDNzw8Y\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"\"></iframe></p>", baseURL: URL(string: "https://www.youtube.com/"))
setNeedsStatusBarAppearanceUpdate()
}
}
my info.plist is right below:
Does anyone know how to solve it?
I know that if I set the key View controller-based status bar appearance
to YES
will help, but In that case it will look like this:
There are unknown reason for changing status bar from white and black, and as for my real project is in a large scale, so it will be nice to solve in the original setting, rather than make every ViewController inherit from one class which is subclass from UIViewController or add dynamic
for overriding prefersStatusBarHidden
and preferredStatusBarStyle
in extension (here just try to force it show update status bar when View controller-based status bar appearance
set to YES
)
Hope there is a solution for View controller-based status bar appearance
set to NO
, that will be very helpful thx.
here is the demo project, it was created by Xcode9.4, feel free to try it with.
Remove Following property from info.plist
file. and Give it programmatically only.
Status bar is initially hidden : NO
View controller-based status bar appearance : NO
Status bar style : UIStatusBarStyleLightContent
It may be work for you.
Use this solution:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoExitFullScreen:) name:@"UIWindowDidBecomeHiddenNotification" object:nil];
...
}
- (void)videoExitFullScreen:(id)sender
{
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
}
Reference more here:
https://github.com/react-native-community/react-native-webview/issues/62
Create one extension of AVPlayerViewController
like below this slo
extension AVPlayerViewController {
open override var prefersStatusBarHidden: Bool {
return false
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With