Ionic ion-view header behind ios status bar

后端 未结 10 2209
礼貌的吻别
礼貌的吻别 2021-01-04 09:15

How do I avoid ionic header from getting behind ios status bar like this?

I created the header with following code:



        
相关标签:
10条回答
  • 2021-01-04 09:37

    The solution with StatusBar.styleDefault(); did not work for me, but calling StatusBar.overlaysWebView(false) did the job.

    First screenshot is UI of the app before calling StatusBar.overlaysWebView(false), you can see that the iOS status bar is over the app and user cannot click the whole area of menu button:

    Now when I call StatusBar.overlaysWebView(false), the iOS status bar is no longer over the menu button:

    0 讨论(0)
  • 2021-01-04 09:37

    Try this for Ionic 5.x, just put index.html inside

    <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    0 讨论(0)
  • 2021-01-04 09:43

    adding margin won't work exactly. It will only create an empty space at the bottom of your screen.

    The fix is to make sure you have viewport-fit = cover in your app's meta tag.

    0 讨论(0)
  • 2021-01-04 09:44

    From: http://www.sitepoint.com/5-ionic-app-development-tips-tricks/

    Ionic has specific classes to deal with this – platform-ios and platform-cordova. Ionic’s pre-built elements target those classes and add in 20px top margin to the buttons in your header to make up for these situations. To get my own custom elements to do the same, I follow the same pattern. For my .search-bar above, I add a margin if we’ve got a .platform-ios.platform-cordova:not(.fullscreen) body class. Example:

    .platform-ios.platform-cordova:not(.fullscreen) .search-bar {
         margin-top: 20px;
    }
    

    This should be the correct answer.

    0 讨论(0)
  • 2021-01-04 09:46

    Add following code in config.xml

    <preference name="SplashShowOnlyFirstTime" value="false" /><br>
    <preference name="SplashScreen" value="screen" /><br>
    <preference name="SplashScreenDelay" value="3000" /><br>
    
    App.component.ts<br>
    Inside constructor<br>
    this.statusBar.overlaysWebView(false);<br>
    this.statusBar.styleLightContent()
    
    0 讨论(0)
  • 2021-01-04 09:48

    This code is working for me with ionic 3 (3.7.1) Open App.scss in app folder then add this code:

    .platform-ios 
    {
      page-home { // replaced by your page HERE
         top: 20px !important;
      }
    }
    
    0 讨论(0)
提交回复
热议问题