2014-11-20 4 views
4

'paginationMode'를 사용하여 iOS 7 용 HTML 콘텐츠 페이지 매김을 만드려고합니다.UIWebView PaginationMode는 항상 흰색 배경을 표시하고 투명하게 만드는 방법은 무엇입니까?

//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]; 

결국 웹보기에는 흰색 배경이 표시됩니다. 어떻게 투명하게 만들 수 있습니까?

+0

투명하게 만들 수는 없지만 직접 볼 수는 있습니다. https://forums.developer.apple.com/thread/27906 – elprup

답변

1

아마도 scrollView의 배경을 지우려고합니까?

webView.scrollView.backgroundColor = [UIColor clearColor]; 

EDIT 그렇게 확인이

UIWebPaginationMode 

을 설정 한 후 배경이 흰색 뒤에이 될 것 같다 : paginationmode의 경우/

+1

을 참조하십시오. – alexzg

+0

작동하지 않습니다 ..... 어떤 도움이 필요합니까? – YuYu

0

는, 정말 객관적 C 코드에서 직접 작동하지 않습니다 .

NSString* path=[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]; 
@"addCSSRule('body', 'background-color: transparent !important; background-image:url(%@); background-repeat: repeat-x; background-size:%fpx %fpx;')",[NSURL fileURLWithPath:path],webView.frame.size.width,webView.frame.size.height]; 

참고 : 그러나, 나는 '몸'태그에 CSS를 주입하여 수행 내 일을 가지고 그것의 UIWebPaginationModeLeftToRight을 위해 ..

+0

작동하지 않습니다. – Bharathi

3

아마 컨텐츠 배경을 제공하려는. 그러나 웹 뷰를 투명하게 설정하고 배경색을 제공하는 기술은 왼쪽에서 오른쪽으로 페이지 매김을 사용할 때 제대로 작동하지 않을 수 있습니다.

나는 CSS를 통해 컨텐츠 배경을 제공함으로써이 문제를 해결하고 this post

- (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]; 
} 

의 도움으로 HTML 내용의 끝 부분에 빈 영역의 문제를 맞추 그리고이 방법 웹뷰 마무리 콘텐츠를로드를 호출합니다.

관련 문제