简体   繁体   English

在 Web 应用程序中隐藏 iPhone 状态栏?

[英]Hide the iPhone status bar in a web application?

Is there a way to disable the status bar in iPhone web apps?有没有办法禁用 iPhone 网络应用程序中的状态栏? I'm working on something that requires a fixed, fullscreen view, and the status bar is rather annoying.我正在做一些需要固定全屏视图的工作,状态栏很烦人。

这不可能。

Unfortunatly, no.不幸的是,没有。 There are only two options black and black-translucent .只有两个选项blackblack-translucent Just note that with black-translucent part of the web frame will be partially visible under the status bar while using black actually pushes the web frame down so it's height is a little smaller.请注意,使用black-translucent的 web 框架部分将在状态栏下部分可见,而使用black实际上会将 web 框架向下推,因此它的高度要小一些。

This is what Apple says in their documentation :这是 Apple 在他们的文档中所说的:

<meta name="apple-mobile-web-app-status-bar-style" content="black">

This meta tag has no effect unless you first specify full-screen mode as described in “apple-mobile-web-app-capable.”除非您首先按照“apple-mobile-web-app-capable”中的说明指定全屏模式,否则此元标记无效

If content is set to default , the status bar appears normal.如果content设置为default ,状态栏显示正常。 If set to black , the status bar has a black background.如果设置为black ,则状态栏具有黑色背景。 If set to black-translucent , the status bar is black and translucent.如果设置为black-translucent ,则状态栏为黑色半透明。 If set to default or black , the web content is displayed below the status bar.如果设置为defaultblack ,则 Web 内容显示在状态栏下方。 If set to black-translucent , the web content is displayed on the entire screen, partially obscured by the status bar.如果设置为black-translucent ,网页内容将显示在整个屏幕上,部分被状态栏遮挡。 The default value is default .默认值为default

The closest I could get (iOS7, I think iOS6 would show darkened status bar) shows the status bar but with a transparent background and does not push down the content of the page;我能得到的最接近的(iOS7,我认为 iOS6 会显示变暗的状态栏)显示状态栏但具有透明背景,并且不会下推页面内容; so you would see the network connection time and battery percent and time at the top of your app.所以你会在你的应用程序顶部看到网络连接时间和电池百分比和时间。

meta tags:
name="apple-mobile-web-app-capable" content="yes"
name="apple-mobile-web-app-status-bar-style" content="black-translucent"

Also, to view any changes requires you to delete the app from your homescreen then add it back again.此外,要查看任何更改,您需要从主屏幕中删除该应用程序,然后重新添加。

As mentioned by andyg303:正如andyg303所提到的:

minimal-ui might have worked on beta, but tested and doesn't work on iPhone (iOS 7.1.2 4s) or iPad (v2 7.1.2). minimum-ui 可能适用于测试版,但经过测试,不适用于 iPhone (iOS 7.1.2 4s) 或 iPad (v2 7.1.2)。

I've seen that you might have to remove the web application from your home screen, and then add it again, if you've added the meta tag, for it to make any difference.我已经看到您可能必须从主屏幕中删除 Web 应用程序,然后再次添加它(如果您添加了元标记),它会有所作为。 Worked for me.为我工作。

This is, at least by now, possible.至少现在,这是可能的。 You need to add a manifest.json to your index.html:您需要将manifest.json添加到您的 index.html:

<link rel="manifest" href="manifest.json">

In projects like Angular, React or Vue don't forget to include this file in the assets otherwise your browser will not know about this file.在 Angular、React 或 Vue 等项目中,不要忘记将此文件包含在资产中,否则您的浏览器将不知道此文件。

You can build your manifest.json like this你可以像这样构建你的 manifest.json

{
   "name": "Your App-name",
   "short_name": "short",
   "display": "standalone",
   "orientation": "landscape",
   "start_url": "http://linkToYourSite:4200",
   "scope": "http://linkToYourSite:4200",
   "icons": [{
        "src": "assets/images/logo.png",
        "sizes": "64x64",
        "type": "image/png"
    }]
}

It is essential that the start_url and the scope are identical or the start_url is at least within the scope. start_url 和范围必须相同或 start_url 至少在范围内。 If you then save your app as a Progressive Web App on your device, all pages within the scope will be displayed without a status bar.如果您随后将您的应用程序另存为设备上的渐进式 Web 应用程序,则范围内的所有页面都将显示而没有状态栏。

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> may be a partial solution: <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">可能是部分解决方案:

https://i.stack.imgur.com/Ylhxt.png https://i.stack.imgur.com/lgGJV.png https://i.stack.imgur.com/Ylhxt.png https://i.stack.imgur.com/lgGJV.png

You can see that the text on status bar can be hidden in the white background, but when you're scrolling, the text will still be there.您可以看到状态栏上的文本可以隐藏在白色背景中,但是当您滚动时,文本仍然存在。

It was added in iOS 7.1它是在 iOS 7.1 中添加的

Simply add minimal-ui to the viewport meta tag, eg:只需将 minimum-ui 添加到视口元标记,例如:

Taken from here: https://forums.whirlpool.net.au/archive/2194915取自此处: https : //forums.whirlpool.net.au/archive/2194915

Please note this only works for iPhone as far as I am aware, not iPad请注意,据我所知,这只适用于 iPhone,不适用于 iPad

<meta name="apple-mobile-web-app-capable" content="yes" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM