IOS显示GIF图片
来源:互联网 发布:苹果平板支持4g网络吗 编辑:程序博客网 时间:2024/06/02 17:11
NSString *path = [[NSBundle mainBundle] pathForResource:@"run" ofType:@"gif"]; NSData *gifData = [NSData dataWithContentsOfFile:path]; UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 120, 100, 100)]; [webView setBackgroundColor:[UIColor clearColor]]; [webView setOpaque:NO]; webView.scalesPageToFit = YES; [webView loadData:gifData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; [self.view addSubview:webView]; [webView release];