使用webView加载大图

2016-12-28  本文已影响0人  短发控丶kk

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

}

上一篇下一篇

猜你喜欢

热点阅读