从iOS上的HTML输入删除选择灰色阴影(Remove selection gray shadow

2019-08-31 08:43发布

我目前正在对HTML富文本编辑器,我的iOS应用程序,因此,安装简单,我有一个UIWebView加载我的编辑代码,HTML输入是一个“CONTENTEDITABLE” DIV。

的问题是,每一次我选择该div输入一些文本时,为浅灰色框显示的输入帧,告诉文本字段已被选择的用户。

注意 :您可以看到在这个快速的效果视频

我的问题是: 如何消除这种浅灰色帧?

我的HTML文件是波纹管:

<html>

<head>

    <style type="text/css">

        :focus{

            outline:0px solid transparent;

        }

        DIV::-moz-focus-inner {
            background-color:#ff0000;
            border: 0;
            padding: 0;
        }

        ul{
            margin-left:-10px;
        }
        ol{
            margin-left:-10px;
        }

        blockquote {

            border-left:#ff0000 5px double;
            margin-left:0px;

        }

    </style>

</head>

<body onload="addImgAttributes();checkBlockquote();" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

    <div
        id="content"
        class="content"
        contenteditable="true"
        style="font-family: Helvetica; background-color:#fff; color:#000; height:258px;"
        autocapitalize="off"
        autocorrect="off"
        autocomplete="off"
        spellCheck="false"
    >
    </div>

</body>

</html>

// ------------------------------------------------ -------------------------------------------------- ----------------编辑1 -----

@StephenJ的评论后,我意识到,这灰框可能是一个UIWebView的子视图,而不是一个css property.I记录从确切时刻该帧出现UIWebView的视图层次,这是日志:

2013-04-17 21:37:00.919 StrangeThings[1182:c07] <UIWebView: 0xa5ec3f0; frame = (7 7; 306 258); layer = <CALayer: 0xa5edf30>>
2013-04-17 21:37:00.919 StrangeThings[1182:c07] <_UIWebViewScrollView: 0xa5f7850; frame = (0 0; 306 258); clipsToBounds = YES; autoresize = H; gestureRecognizers = <NSArray: 0xa5f7e20>; layer = <CALayer: 0xa5f7aa0>; contentOffset: {0, 0}>
2013-04-17 21:37:00.920 StrangeThings[1182:c07] <UIImageView: 0xa5f90c0; frame = (0 0; 54 54); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f9120>>
2013-04-17 21:37:00.920 StrangeThings[1182:c07] <UIImageView: 0xa5f9030; frame = (0 0; 54 54); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f9090>>
2013-04-17 21:37:00.920 StrangeThings[1182:c07] <UIImageView: 0xa5f8fa0; frame = (0 0; 54 54); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f9000>>
2013-04-17 21:37:00.921 StrangeThings[1182:c07] <UIImageView: 0xa5f8b90; frame = (0 0; 54 54); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8f70>>
2013-04-17 21:37:00.921 StrangeThings[1182:c07] <UIImageView: 0xa5f8b00; frame = (-14.5 14.5; 30 1); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8b60>>
2013-04-17 21:37:00.922 StrangeThings[1182:c07] <UIImageView: 0xa5f8a70; frame = (-14.5 14.5; 30 1); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8ad0>>
2013-04-17 21:37:00.922 StrangeThings[1182:c07] <UIImageView: 0xa5f89e0; frame = (0 0; 1 30); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8a40>>
2013-04-17 21:37:00.922 StrangeThings[1182:c07] <UIImageView: 0xa5f8950; frame = (0 0; 1 30); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f89b0>>
2013-04-17 21:37:00.923 StrangeThings[1182:c07] <UIImageView: 0xa5f88c0; frame = (0 228; 306 30); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8920>>
2013-04-17 21:37:00.923 StrangeThings[1182:c07] <UIImageView: 0xa5f8750; frame = (0 0; 306 30); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa5f8630>>
2013-04-17 21:37:00.924 StrangeThings[1182:c07] <UIWebBrowserView: 0xc270400; frame = (0 0; 306 258); text = ''; gestureRecognizers = <NSArray: 0xa5f5ac0>; layer = <UIWebLayer: 0xa5f0820>>
2013-04-17 21:37:00.925 StrangeThings[1182:c07] <UIHighlightView: 0xa5ef210; frame = (-4 -4; 314 266); opaque = NO; layer = <CALayer: 0xa5c0730>>
2013-04-17 21:37:00.925 StrangeThings[1182:c07] <UIImageView: 0xa0bebc0; frame = (0 251; 306 7); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0xa0bec60>>
2013-04-17 21:37:00.925 StrangeThings[1182:c07] <UIImageView: 0xa0b37d0; frame = (299 0; 7 258); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0xa0becd0>>

分析所有这些子视图我发现一个名为后UIHighlightView ,正如其名字确认,这种观点可能会突出webView.So我的第二个问题是: 如何删除这个观点?

Answer 1:

这是因为设置以下CSS规则一样简单。

div {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

这使得应用阴影透明的,所以它看起来像它不见了。

编辑:这是一个演示链接 。



文章来源: Remove selection gray shadow from html input on iOS