-(void)gifImageView:(NSString *)imageName { NSLog(@"%@",imageName); // 设定位置和大小 CGRect frame = CGRectMake(50,50,0,0); frame.size = [UIImage imageNamed:imageName].size; NSArray *imageArray = [imageName componentsSeparatedByString:@"."]; // 读取gif图片数据 NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:[imageArray objectAtIndex:0] ofType:[imageArray objectAtIndex:1]]]; // view生成 UIWebView *webView = [[UIWebView alloc] initWithFrame:frame]; webView.userInteractionEnabled = NO;//用户不可交互 [webView loadData:gif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; [self.view addSubview:webView]; }