【问题标题】:iOS remove shadow from UIWebViewiOS 从 UIWebView 中移除阴影
【发布时间】:2015-06-12 12:07:48
【问题描述】:

我正在尝试移除加载和显示 .pdf 文件的 UIWebView 周围的阴影。我曾尝试实施 2010 年至 2013 年间发布的解决方案,但没有成功。我尝试过的解决方案包括:

self.contentWebView.layer.shadowOpacity = 0.0;
    for (UIView* view in self.contentWebView.subviews)
    {
        view.layer.shadowOpacity = 0.0;
    }

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

谢谢。

【问题讨论】:

    标签: ios objective-c iphone uiwebview


    【解决方案1】:

    可能duplicate of this?很多解决方案,但最近的是:

    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    得票较多的老一是:

    -(void)viewDidLayoutSubviews {
        [super viewDidLayoutSubviews];
    
        // Assuming self.webView is our UIWebView
        // We go though all sub views of the UIWebView and set their backgroundColor to white
        UIView *v = self.webView;
        while (v) {
            v.backgroundColor = [UIColor whiteColor];
            v = [v.subviews firstObject];
        }
    }
    

    【讨论】:

    • 不,这修复了加载 .pdf 时 UIWebView 周围的黑色边框。我说的是每个 UIWebView 都有的默认阴影。
    猜你喜欢
    • 2012-01-18
    • 1970-01-01
    • 2010-11-07
    • 1970-01-01
    • 2017-09-08
    • 2016-09-16
    • 2013-10-01
    • 1970-01-01
    相关资源
    最近更新 更多