BhushanVU
BhushanVU

Reputation: 3455

How to control spinning of UIActivityIndicatorView?

I have seen many apps which can control spinning rate of UIActivityIndicatorView. One example is Instagram, while refreshing latest feed when you drag UITableView down slowly the UIACtivityIndicatorView loads slowly one petal at a time. Just wondering how is this achievable with native UIActivityIndicatorView.

Upvotes: 1

Views: 250

Answers (2)

Tom
Tom

Reputation: 373

So I'm guessing you're using a UITableView (tableView). I think it's native what you're trying to achieve.

You have to use a UIRefreshControl.

@property (nonatomic, strong) UIRefreshControl *refreshControl;

And use it like this in viewDidLoad of your viewController for example

// The refresh view
self.refreshControl = [[UIRefreshControl alloc]init];
self.refreshControl.tintColor = [UIColor whiteColor];
self.refreshControl.backgroundColor = [UIColor blackColor];
[self.tableView addSubview:refreshControl];
[refreshControl addTarget:self action:@selector(refreshWhatYouWant:) forControlEvents:UIControlEventValueChanged];

Now if you pull to refresh your tableView slowly, you'll have the UIActivityIndicatorView loading one petal at a time.

Hope it helps.

Tom

Upvotes: 1

Mihir Mehta
Mihir Mehta

Reputation: 13833

I think you need to use custom control ....As far as I know UIActivityIndicatorView doesn't provide you any API for controlling speed of indicator

Upvotes: 0

Related Questions