-1

This is my code that I have written in my project. Instead of a spinner I want to show an image.

progress= [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(125, 50, 30, 30)];
progress.backgroundColor = [UIColor redColor];

progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[self.view bringSubviewToFront:progress];
SiHa
  • 7,830
  • 13
  • 34
  • 43
jeevan
  • 67
  • 1
  • 13

3 Answers3

1

You can not do that as UIActivityIndicatorView is the system activity indicator. So if you want to do that then either you can create custom view for the same OR UIImageView supports animating several images in a loop(for, while) OR you can also add gif image for animation instead of UIActivityIndicatorView.

Maddy
  • 311
  • 2
  • 11
  • "UIImageView supports animating several images in a loop(for, while) " - actually, I don't think you can animate the frames manually. You call the methods `startAnimating()` and `stopAnimating()`. – Nicolas Miari Oct 04 '16 at 08:18
0

Put this code in your viewDidload() . BuildingIcon_ImageView is my imageview and when your image you want to load after set image hide UIActivityIndicatorView.

Code :

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
 [indicator startAnimating];
 [indicator setCenter:BuildingIcon_ImageView.center];
 [BuildingIcon_ImageView addSubview:indicator];

BuildingIcon_ImageView.image=image;
[indicator removeFromSuperview];
Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
Himanshu Moradiya
  • 4,769
  • 4
  • 25
  • 49
0

i have resolved my issue long back , posting lately this is my answer it may helpful for other thats why i am posting here.

by using NVActivityIndicatorView i resolved my problem .NVActivityIndicatorView we can choose number of custom designs.

jeevan
  • 67
  • 1
  • 13