美文网首页
使用webView加载大图

使用webView加载大图

作者: 短发控丶kk | 来源:发表于2016-12-28 17:24 被阅读0次

    - (void)viewDidLoad {  

      [super viewDidLoad];    self.title = @"充值引导";        UIWebView *webview = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64)];    UIImage *image = [UIImage imageNamed:@"zhidao"];    webview.scalesPageToFit = YES;    NSString *htmlString = [self htmlForJPGImage:image];    NSString *content = [NSString stringWithFormat:@"%@", htmlString];    [webview loadHTMLString:content baseURL:nil];    [self.view addSubview:webview];

    }

    //image转html函数

    - (NSString *)htmlForJPGImage:(UIImage *)image{    NSData *imageData = UIImageJPEGRepresentation(image,1.f);    NSString *imageSource = [NSString stringWithFormat:@"data:image/jpg;base64,%@",[imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]];    return [NSString stringWithFormat:@"大图", imageSource];

    }

    相关文章

      网友评论

          本文标题:使用webView加载大图

          本文链接:https://www.haomeiwen.com/subject/mrnyvttx.html