Capacitor-JS status bar overlaps in IOS
P粉543344381
P粉543344381 2023-12-29 16:04:36
0
1
402

I'm using NuxtJS with capacitor. The top status bar on iOS devices overlaps when we scroll. I also added "ios": {"contentInset": "always"} in Capacitor.config.json.

Although I also included the CSS, it creates extra space at the top.

body {
   padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
     env(safe-area-inset-left);
 }

P粉543344381
P粉543344381

reply all(1)
P粉198670603

This can be achieved by adding the following lines in the CAPViewBridgeController file

webView?.frame.origin = CGPoint(x: 0, y: UIApplication.shared.statusBarFrame.size.height)

webView?.frame.size.height = UIScreen.main.bounds.size.height - UIApplication.shared.statusBarFrame.size.height;

Search for the following functions and update. The function should look like this

extension CAPBridgeViewController: CAPBridgeDelegate {
    internal var bridgedWebView: WKWebView? {
        webView?.frame.origin = CGPoint(x: 0, y: UIApplication.shared.statusBarFrame.size.height)
        webView?.frame.size.height = UIScreen.main.bounds.size.height - UIApplication.shared.statusBarFrame.size.height;
        return webView
    }

    internal var bridgedViewController: UIViewController? {
        return self
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!