我正在使用此处找到的代码http://blog.blackwhale.at/?p=336activityIndicator
在当前版本的 xCode 中创建自定义。此代码使用.png
数组中的一系列图像,然后以设置的间隔显示它们以创建动画加载图像,然后您可以随时将其放置在屏幕上(并假设您可以以某种方式将其删除)。
在我的主 ViewController.m 文件中,我的viewDidLoad
部分中有以下代码:
/* --- START CUSTOM ACTIVITY INDICATOR */
//Create the first status image and the indicator view
UIImage *statusImage = [UIImage imageNamed:@"activity1.png"];
UIImageView *activityImageView = [[UIImageView alloc]
initWithImage:statusImage];
//Add more images which will be used for the animation
activityImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"activity1.png"],
[UIImage imageNamed:@"activity2.png"],
[UIImage imageNamed:@"activity3.png"],
[UIImage imageNamed:@"activity4.png"],
[UIImage imageNamed:@"activity5.png"],
[UIImage imageNamed:@"activity6.png"],
[UIImage imageNamed:@"activity7.png"],
[UIImage imageNamed:@"activity8.png"],
[UIImage imageNamed:@"activity9.png"],
[UIImage imageNamed:@"activity10.png"],
[UIImage imageNamed:@"activity11.png"],
[UIImage imageNamed:@"activity12.png"],
nil];
//Set the duration of the animation (play with it
//until it looks nice for you)
activityImageView.animationDuration = 0.6;
//Position the activity image view somewhere in
//the middle of your current view
activityImageView.frame = CGRectMake(
self.view.frame.size.width/2
-statusImage.size.width/2,
self.view.frame.size.height/1.2
-statusImage.size.height/1.2,
statusImage.size.width,
statusImage.size.height);
//Start the animation
[activityImageView startAnimating];
//Add your custom activity indicator to your current view
[self.view addSubview:activityImageView];
/* --- END CUSTOM ACTIVITY INDICATOR */
我想清除/删除/隐藏activityImageView
元素,因为我只希望它在应用程序首次启动时显示,直到UIWebView
完成加载。
我想调用它并让 gif 出现 whilewebViewDidStartLoad
然后清除 when webViewDidFinishLoad
。有人帮忙??