CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
=========================================写了一个去掉所有字符的
NSString *name = @"帝子今何在?槛外长江空自流";
最后的结果NSCharacterSet *chatSet = [NSCharacterSet characterSetWithCharactersInString:@"。?,;!)(~、|、:"];
//按照 特殊字符 切割字符串
NSArray *arr = [name componentsSeparatedByCharactersInSet:chatSet];
NSMutableString *tmpStr = [[NSMutableString alloc]init];
for (NSString *str in arr) {
if (str.length>0)
{
[tmpStr appendString:@"*******"];
[tmpStr appendString:str];
[tmpStr appendString:@"*******
"];
}
}
NSString *htmlString = [NSString stringWithFormat:@"%@",tmpStr];
UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
[webView loadHTMLString:htmlString baseURL:nil];
[self.view addSubview:webView];
网友评论