我创建了一个字符串并使用 Java字符串进行评估
这就是我写的:
Nsstring *varMySheet = @"var mySheet = document.styleSheets[0];";Nsstring *addCSSRule = @"function addCSSRule(selector,newRule) {""if (mySheet.addRule) {""mySheet.addRule(selector,newRule);" // For Internet Explorer"} else {""ruleIndex = mySheet.CSSRules.length;""mySheet.insertRule(selector + '{' + newRule + ';}',ruleIndex);" // For firefox,Chrome,etc."}""}";Nsstring *insertRule1 = [Nsstring stringWithFormat:@"addCSSRule('HTML','padding: 0px; height: %fpx; -webkit-column-gap: 0px; -webkit-column-wIDth: %fpx;')",webVIEw.frame.size.height,webVIEw.frame.size.wIDth];Nsstring *insertRule2 = [Nsstring stringWithFormat:@"addCSSRule('p','text-align: justify;')"];Nsstring *setTextSizeRule = [Nsstring stringWithFormat:@"addCSSRule('body','-webkit-text-size-adjust: %d%%;')",currentTextSize];Nsstring *setHighlightcolorRule = [Nsstring stringWithFormat:@"addCSSRule('highlight','background-color: yellow;')"]; // this is what change the text style Nsstring *insertRule3 = [Nsstring stringWithFormat:@"addCSSRule('HTML,body,div,p,span,a','Font-family: arial;')"];Nsstring *changecolor = [Nsstring stringWithFormat:@"addCSSRule('HTML,'color: #1122CC;')"];[webVIEw stringByEvaluatingJavaScriptFromString:varMySheet];[webVIEw stringByEvaluatingJavaScriptFromString:addCSSRule];[webVIEw stringByEvaluatingJavaScriptFromString:insertRule1];[webVIEw stringByEvaluatingJavaScriptFromString:insertRule2];[webVIEw stringByEvaluatingJavaScriptFromString:setTextSizeRule];[webVIEw stringByEvaluatingJavaScriptFromString:setHighlightcolorRule]; [webVIEw stringByEvaluatingJavaScriptFromString:insertRule3]; [webVIEw stringByEvaluatingJavaScriptFromString:changecolor];总结
以上是内存溢出为你收集整理的iphone – 如何在iOS中更改ePub Book的字体颜色和字体样式?全部内容,希望文章能够帮你解决iphone – 如何在iOS中更改ePub Book的字体颜色和字体样式?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)