如何控制 UIActivityIndi​​catorView 的旋转?

How to control spinning of UIActivityIndicatorView?

我见过很多应用程序可以控制 spinning rate of UIActivityIndicatorView。 一个示例是 Instagram,当您缓慢向下拖动 UITableView 时刷新最新提要时,UIACtivityIndicatorView 一次缓慢加载一个花瓣。 只是想知道如何使用原生 UIActivityIndicatorView.

实现这一点

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

所以我猜您使用的是 UITableView (tableView)。我认为这是您要实现的目标。

你必须使用 UIRefreshControl

@property (nonatomic, strong) UIRefreshControl *refreshControl;

然后在 viewController 的 viewDidLoad 中像这样使用它,例如

// 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];

现在,如果您拉动以缓慢刷新 tableView,您将 UIActivityIndicatorView 一次加载一个花瓣。

希望对您有所帮助。

汤姆