iOS用UIWebView顯示GIF圖片
阿新 • • 發佈:2019-01-25
-(void) getGifDataFromUrl:(NSString*)urlStr andShowInWebViewWithFatherView:(UIView*)fatherView { NSURL *gifUrl = [NSURL URLWithString:urlStr]; NSData *gifData = [NSData dataWithContentsOfURL:gifUrl]; UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; [webView setOpaque:NO]; [webView setScalesPageToFit:YES]; [webView loadData:gifData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; [fatherView addSubview:webView]; }