我想以完成图像的形式显示进度活动。一个简单的例子是,当我们从应用商店安装应用程序时,我们可以看到图像图标随着下载的完成而变满,即我获得要下载的总字节数,但我希望以图标图像的形式显示完成的进度,即根据完成的字节,希望显示完成的图标图像,我正在寻找那种进度活动。有人这么做过吗。请帮帮忙。
发布于 2014-06-11 17:41:37
您需要一个空图像和部分填充图像的图像序列,直到图像完全填充。然后,它必须是动画,以便输出将看起来像是图像正在被填充。
示例代码将如下所示:
UIImageView *animationView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,320, 460)];//specify your size here
animationView.contentMode = UIViewContentModeCenter;
animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
[UIImage imageNamed:@"5.png"],
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"7.png"],
[UIImage imageNamed:@"8.png"],
[UIImage imageNamed:@"9.png"],
[UIImage imageNamed:@"10.png"],nil];
animationView.animationDuration = 1.5f;
animationView.animationRepeatCount= 0;
[animationView startAnimating];
[self.view addSubview:animationView]; 发布于 2014-06-11 21:04:41
如果你没有下载图片,为什么不在图片上使用一个CAShapeLayer作为遮罩。换句话说,你的图像一直在那里,但随着遮罩的改变,更多的图像变得可见。
如果遮罩是圆的单个切片,则可以使用NSURLSession/NSURLConnection委托在圆的中心点周围应用CATransform,然后重新计算遮罩的bezierpath路径。在委托返回之前,应用新的遮罩,您将得到一个循环进度视图,在该视图中,每次调用委托时,图像的更多部分将变为可见。
https://stackoverflow.com/questions/24157962
复制相似问题