简体   繁体   中英

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 .

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

我认为您需要使用自定义控件...据我所知, UIActivityIndicatorView不提供任何用于控制指标速度的API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM