UIWebView PaginationMode always show white background, how to make it transparent?

前端 未结 3 628
一生所求
一生所求 2021-02-10 13:48

I try to use \'paginationMode\' to make my html-content pagination for iOS 7 latter.

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


        
3条回答
  •  遥遥无期
    2021-02-10 14:24

    In case of paginationmode, it's not really working directly from objective c code. However, I got my job done by injecting CSS for 'body' tag:

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

    Note : its for UIWebPaginationModeLeftToRight..

提交回复
热议问题