第二种方法:使用UIAlertView and UIActivityIndicatorView
代码如下:
//加载网页动画
- (void)webViewDidStartLoad:(UIWebView *)webView{
if (myAlert==nil){
myAlert = [[UIAlertView alloc] initWithTitle:nil
message: @"读取中..."
delegate: self
cancelButtonTitle: nil
otherButtonTitles: nil];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(120.f, 48.0f, 38.0f, 38.0f);
[myAlert addSubview:activityView];
[activityView startAnimating];
[myAlert show];
}
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[myAlert dismissWithClickedButtonIndex:0 animated:YES];
}
方法三:使用UIWebView来加载gif图片,除非你要用到webView,不然就不要使用这种方式来实现
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)代码如下:
NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"1" ofType:@"gif"]];
// view生成
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(100, 100, 70, 30)];
webView.userInteractionEnabled = NO;//用户不可交互
[webView loadData:gif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];
[self.view addSubview:webView];
以上所述就是本文的全部内容了,希望大家能够喜欢。