UIWebView 上面(反弹部分)的背景颜色

发布于 2024-10-21 08:41:59 字数 272 浏览 5 评论 0原文

我认为这应该不是一个大问题,但我自己找不到解决方案。一如既往:p 我有一个 UIWebView,其背景颜色设置为clearColor,但是当我尝试向下滚动太多时,我会在加载的 HTML 上方看到深灰色的“弹跳区域”。我想将其更改为透明/白色。有什么办法可以改变这个吗?
题外话:我读到继承 UIScrollView 的类可以具有属性ounce = NO,然后它们根本不会显示弹跳区域。即使 UIWebView 继承了该类,我也不想阻止它弹跳,可以这么说,只是“用白色弹跳它”...

非常感谢,
卢卡

I think this shouldn't be a big problem, but I can't find the solution on my own. As always :p I have an UIWebView that has background color set to clearColor but when I try to scroll down too much I get the "bouncing area" above loaded HTML in dark gray color. I would like to change this to transparent/white. Is there any way of changing this?
Digression: I read that classes inheriting UIScrollView can have property bounce = NO and then they won't show the bouncing area at all. Even if UIWebView was inheriting that class I wouldn't like to stop it from bouncing, just "bounce it in white" so to speak...

Thanks a lot,
Luka

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七婞 2024-10-28 08:41:59

Take a look at the following answer

Remove gradient background from UIWebView?

白色秋天 2024-10-28 08:41:59

设置 webview 的背景颜色并将不透明设置为 NO:

[self.webView setBackgroundColor:[UIColor whiteColor]];
[self.webView setOpaque:NO];

或者尝试设置透明颜色作为背景:

[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];

Set the webview's background colour and set opaque to NO:

[self.webView setBackgroundColor:[UIColor whiteColor]];
[self.webView setOpaque:NO];

Or try setting clear color as background:

[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];
末蓝 2024-10-28 08:41:59

@Ladislav:谢谢你给我指出了正确的主题:)
现在,以下帖子 从 UIWebView 中删除渐变背景? 正是我所需要的,所以很抱歉我打开了新线程。我搜索了论坛,但由于没有这个渐变、反弹背景或背景的名称,所以我之前找不到它。

总结如下:

1.在代码中将Web视图的backgroundColor设置为clearColor!界面生成器中的原因没有产生想要的结果。

myWebView.backgroundColor = [UIColor clearColor];

这条线只会使“过度滚动”背景看起来更亮,但要完全删除它(使其透明/白色),我们需要隐藏在 myWebView 的子视图中找到的所有 imageView:

for (UIView* subView in [self.myWebView subviews])
{
    if ([subView isKindOfClass:[UIScrollView class]]) {
        for (UIView* shadowView in [subView subviews])
        {
            if ([shadowView isKindOfClass:[UIImageView class]]) {
                [shadowView setHidden:YES];
            }
        }
    }
}

谢谢大家,祝您周末愉快

@Ladislav: thanks for pointing me to the right subject :)
Now, the following post Remove gradient background from UIWebView? is exactly what I needed, so I am sorry I opened the new thread. I searched the forum but since there is no name for this gradient, bounce background or background I couldn't find it earlier.

The summary would be:

1.Setting the backgroundColor of web view to clearColor !in code! cause in interface builder is not producing the wanted result.

myWebView.backgroundColor = [UIColor clearColor];

this line will only make the "overscroll" background look lighter, but to remove it totally (make it transparent/white) we need to hide all imageViews found in subViews of our myWebView:

for (UIView* subView in [self.myWebView subviews])
{
    if ([subView isKindOfClass:[UIScrollView class]]) {
        for (UIView* shadowView in [subView subviews])
        {
            if ([shadowView isKindOfClass:[UIImageView class]]) {
                [shadowView setHidden:YES];
            }
        }
    }
}

Thanks everyone, I wish you a great weekend

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文