使UIActivityIndicator的尺寸与UIRefreshControl的尺寸相同
问题描述:
我想让UIActivityIndicator的尺寸与UIRefreshControl的尺寸相同,因为有时我需要手动刷新屏幕,有时候数据刷新时不需要拉动屏幕,所以我需要模拟活动指标。使UIActivityIndicator的尺寸与UIRefreshControl的尺寸相同
_refreshControl = [[UIRefreshControl alloc] init];
_refreshControl.tintColor = [UIColor grayColor];
[_refreshControl addTarget:self action:@selector(refreshItems) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:_refreshControl];
UIView *activityIndicatorWrapper = [[UIView alloc] initWithFrame:_refreshControl.frame];
[self.collectionView addSubview:activityIndicatorWrapper];
_activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicatorWrapper.frame = _refreshControl.bounds;
[activityIndicatorWrapper addSubview:_activityIndicator];
[_activityIndicator startAnimating];
[_activityIndicator autoCenterInSuperview];
_activityIndicator.hidesWhenStopped = YES;
问题是,大小是不同的,即使我让他们在同一帧..
答
我试图做到这一点为好。我不认为这是可能的,因为我们无法看到UIKit在幕后做了什么。
你是如何解决它的?到目前为止,我跳过手动刷新,因为它更麻烦 –