从 UIWebView 中删除渐变背景?

Remove gradient background from UIWebView?(从 UIWebView 中删除渐变背景?)

本文介绍了从 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 underside的问题不同)

(note: not the same question as UIWebView underside)

推荐答案

啊哈,是的,术语失败了.我根本不会称它为影子,但 c'est la vie.这是我实现效果的类型安全代码.总结一下:这将隐藏滚动视图的任何图像视图子项.它不像 (objectAtIndex:0) 方法那样容易受到更改,因此如果 Apple 重新排序 webView 控件的子项,它将正常工作,但仍然依赖于渐变效果由父级到滚动的图像视图应用的事实视图(并且确实有一个支持 Web 视图的滚动视图).

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 中删除渐变背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:从 UIWebView 中删除渐变背景?

基础教程推荐