从UIWebView中删除渐变背景? [英] Remove gradient background from UIWebView?

查看:119
本文介绍了从UIWebView中删除渐变背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从UIWebView中删除渐变 - 如果您过度滚动顶部或底部,则会看到该渐变。
此代码

How do remove the gradient from a UIWebView - the one that you see if you overscroll the top or bottom. This code

webView.backgroundColor = [UIColor whiteColor];

只是改变渐变的颜色,它不会删除它。如何做到这一点?

just changes the color of the gradient, it doesn't removes it. How can this be done?

(注意:与 UIWebView底层

推荐答案

啊哈,是的术语失败了。我根本不会称它为阴影,但是我可以说。这是我的类型安全代码,以实现这种效果。总结一下:这将隐藏滚动视图的任何图像视图子项。它不像(objectAtIndex:0)方法那样容易改变,所以如果Apple重新订购webView控件的子节点它会正常工作,但仍然依赖于通过图像视图应用渐变效果的事实。视图(并且确实存在支持Web视图的scrollview)。

Aha, yes terminology fail. I wouldn't call that a shadow at all, but c'est la vie. Here is my type-safe code to achieve the effect. To summarise: this will hide any image-view children of the scroll view. It's not as vulnerable to change as the (objectAtIndex:0) methods, so if Apple re-order the children of the webView control it will work fine, but still relies on the fact that the gradient effect is applied by imageviews parented to the scroll view (and that there is indeed a scrollview underpinning the web view).

{
    webView.backgroundColor = [UIColor whiteColor];
    for (UIView* subView in [webView subviews])
    {
        if ([subView isKindOfClass:[UIScrollView class]]) {
            for (UIView* shadowView in [subView subviews])
            {
                if ([shadowView isKindOfClass:[UIImageView class]]) {
                    [shadowView setHidden:YES];
                }
            }
        }
    }
}

这篇关于从UIWebView中删除渐变背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆