0

I want to show progress activity in the form of image getting completed. A simple example is when we install app from app store, we can see the image icon getting full as downloading gets completed, i.e. I get total bytes to be downloaded but I want to show progress in the form of icon image getting completed, i.e. according to bytes completed, want to show that icon image completed, I am looking for that kind of progress activity. Has anybody done that. Please help.

  • first thing is that how do you download the image.? if you are using AFnetworking there there is provide delegate for getting byte. so this is unclear question. – Nitin Gohel Jun 11 '14 at 08:24
  • Sorry for unclear question, the thing is that I am not downloading image, I get total bytes to be downloaded, so according to bytes downloaded I have to show progess, now the activity progress should be in the form, as when we install app in iphone there is progress of icon of app getting completed according to bytes installed. I want to show progress in that way, don't want simple circular progress but progress in the form of image getting completed. – user3603583 Jun 11 '14 at 08:33

2 Answers2

0

You need an image sequence of empty image and partially filled images until image is fully filled. Then it must be animated so output will look like image is getting filled.

A sample code would look like,

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];       
Rukshan
  • 7,902
  • 6
  • 43
  • 61
  • thanks for the answer, but in these case animation duration is not going to remain fixed, like if I am downloading, it will depend on download speed when animation has to be completed, i.e. it will depend on the bytes yet to be downloaded and total bytes to be downloaded, duration will not be fixed – user3603583 Jun 11 '14 at 10:45
0

If you're not downloading the image the why not use a CAShapeLayer used as a mask over your image. In other words your image is there the whole time but more of it becomes visible as your mask changes.

If your mask was a single slice of a circle you could then use the NSURLSession/NSURLConnection delegate to apply a CATransform around the centre point of the circle and then recalculate the bezierpath of the mask. Before the delegate returns apply the new mask and you would end up with a circular progress view where more of your image becomes visible with each call to the delegate.

Sadiq Jaffer
  • 500
  • 2
  • 10
  • thanks, it seems it can be done in this way, is there any such sample code available as I have never worked with 'CAShapeLayer' or 'bezierpath' – user3603583 Jun 12 '14 at 06:22
  • Have a look at [this](http://stackoverflow.com/questions/18835915/cashapelayer-animation-arc-from-0-to-final-size) post on SO as the original poster was trying to achieve something very similar to what I described – Sadiq Jaffer Jun 12 '14 at 14:59