首页 \ 问答 \ iOS非阻塞状态栏(iOS non blocking status bar)

iOS非阻塞状态栏(iOS non blocking status bar)

我试图在状态栏后面放置一个图像。

我可以将它变成透明的,但它仍然阻止图像出现在它后面。

有人知道如何使状态栏与可编辑屏幕和/或安全区域分开吗? 我不想删除它,只是想把东西放在它后面。

这是IB的样子 在这里输入图像描述

override func viewWillAppear(_ animated: Bool) {
        setNeedsStatusBarAppearanceUpdate()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        venueInfoTableView.dataSource = self
        venueInfoTableView.delegate = self

        // Do any additional setup after loading the view, typically from a nib.

        venueInfoTableView.separatorStyle = .none
    }

    override var preferredStatusBarStyle : UIStatusBarStyle {
        return UIStatusBarStyle.lightContent
        //return UIStatusBarStyle.default   // Make dark again
    }

结果如下

在这里输入图像描述


I'm trying to place an image behind the status bar.

I'm able to turn it transparent but It's still blocking the image from appearing behind it.

Does anybody know how to make the status bar apart of the editable screen and/or safe area? I don't want to delete it, just want to put stuff behind it.

Here's what IB looks like enter image description here

Code

override func viewWillAppear(_ animated: Bool) {
        setNeedsStatusBarAppearanceUpdate()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        venueInfoTableView.dataSource = self
        venueInfoTableView.delegate = self

        // Do any additional setup after loading the view, typically from a nib.

        venueInfoTableView.separatorStyle = .none
    }

    override var preferredStatusBarStyle : UIStatusBarStyle {
        return UIStatusBarStyle.lightContent
        //return UIStatusBarStyle.default   // Make dark again
    }

And here's the result

enter image description here


原文:https://stackoverflow.com/questions/50599642
更新时间:2023-04-09 22:04

最满意答案

您可以将引用保存到某个全局变量中的焦点输入中。
然后用它将焦点设置回文本追加功能

<html>
    <body>    
        <script>
            var selectedInputId;

            function clickBtn(key) {
                if (selectedInputId != null) {
                    selectedInputId.value = selectedInputId.value + key.innerHTML;
                    selectedInputId.focus();
                }
            }
        </script>

        <a href="#" class="btn btn-default btn-lg digit" onclick="javascript:{clickBtn(this)}">q</a>

        <input type="text" id="id1" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id2" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id3" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id4" onfocus="javascript:{selectedInputId=this;}" />
    </body>
</html>

You can save the reference to the focused input in some global variable.
And use it to set the focus back in text-appending function

<html>
    <body>    
        <script>
            var selectedInputId;

            function clickBtn(key) {
                if (selectedInputId != null) {
                    selectedInputId.value = selectedInputId.value + key.innerHTML;
                    selectedInputId.focus();
                }
            }
        </script>

        <a href="#" class="btn btn-default btn-lg digit" onclick="javascript:{clickBtn(this)}">q</a>

        <input type="text" id="id1" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id2" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id3" onfocus="javascript:{selectedInputId=this;}" />
        <input type="text" id="id4" onfocus="javascript:{selectedInputId=this;}" />
    </body>
</html>

相关问答

更多
  • 当我点击它,字段没有得到焦点。 我可以通过按“Tab键”访问该字段 听起来你已经取消了mousedown事件的默认动作。 通过HTML和JS搜索onmousedown处理程序,并查找一行。 return false; 这一行可能会阻止您通过点击进行聚焦。 Re:你的评论,我假设你不能编辑添加这个处理程序的代码? 如果可以的话,最简单的解决办法就是去除return false; 声明。 有没有办法通过不覆盖来添加事件触发器的功能? 这取决于处理程序如何附加。 如果使用传统的注册方法(例如element.on ...
  • 您的HTML似乎被
    包装。 您应该能够通过向JS添加以下内容来阻止任何回发: $('form').submit(function(event) { event.preventDefault(); }); 您可能希望使选择器更具体。 It appears that your HTML is wrapped by a . You should be able to prevent any postbacks by adding the following to your JS: ...
  • 使用+(concatenation operator)运算符连接变量i 连接运算符(+)将两个字符串值连接在一起,返回另一个字符串,该字符串是两个操作数字符串的并集。 var i = 0; function increment() { i += 1; } function addfieldFunction() { var r = document.createElement('div'); var y = document.createElement("INPUT"); ...
  • 您可以将引用保存到某个全局变量中的焦点输入中。 然后用它将焦点设置回文本追加功能