gpt4 book ai didi

ios - UIWebView PaginationMode 总是显示白色背景,如何让它透明?

转载 作者:可可西里 更新时间:2023-11-01 05:40:52 28 4
gpt4 key购买 nike

我尝试使用“paginationMode”为 iOS 7 后者制作我的 html 内容分页。

//set webview to transparent
webView.backgroundColor = [UIColor clearColor];
webView.opaque = NO;

// set multi-columns
webView.paginationBreakingMode = UIWebPaginationBreakingModePage;
webView.paginationMode = UIWebPaginationModeLeftToRight;
webView.pageLength = webView.bounds.size.width;

// set html to transparent background
NSString *transparent = @"addCSSRule('html', 'background-color: transparent')";
[webView stringByEvaluatingJavaScriptFromString:transparent];

但最后网页 View 总是显示白色背景,我怎样才能让它透明?

最佳答案

您可能想提供内容背景。但是,当我们使用从左到右的分页时,将 webview 设置为透明并为 View 提供背景颜色的技术可能无法正常工作。

我通过 CSS 提供内容背景解决了这个问题,并在 this post 的帮助下解决了 html 内容末尾的空白区域问题。

    - (void)addExtraContentView
{
UIWebView* wv = self.webView;
if(!self.viewExtraContent)
{
NSString* width = [wv stringByEvaluatingJavaScriptFromString:@"document.documentElement.offsetHeight;"];
CGFloat contentHeight = [width floatValue];
CGFloat contentWidth = wv.scrollView.contentSize.width;
CGFloat y = (int)contentHeight % (int)wv.frame.size.height;
self.viewExtraContent = [[UIView alloc] initWithFrame:CGRectMake(contentWidth - wv.frame.size.width, y, wv.frame.size.width, (wv.frame.size.height))];
}
self.viewExtraContent.backgroundColor = [BookReaderSettings shared].backgroundColor;
[wv.scrollView addSubview:self.viewExtraContent];
}

并在 webview 完成加载内容时调用此方法。

关于ios - UIWebView PaginationMode 总是显示白色背景,如何让它透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27031092/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com