我在集合视图中添加了一个刷新控件,一切都工作正常,但是当我设置collectionView.contentInset = UIEdgeInsetsMake(0, 20, 20, 20)时,刷新控件的宽度保持不变,但向右移动了20像素,因此没有居中显示。为了使其正确,应将控件减小40像素。
self.collectionView = [[UICollectionView alloc] initWithFrame:rect collectionViewLayout:flowLayout];
self.collectionView.contentInset = UIEdgeInsetsMake(0, 20, 20, 20)
UIRefreshControl* pullDownRefresh = [[UIRefreshControl alloc] init];
[pullDownRefresh addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:pullDownRefresh];
我已经尝试过在添加视图后手动设置宽度(也在viewWillLayoutSubviews中尝试),并且调整了自动调整大小的掩码,但都没有效果。
有什么想法吗?我猜我需要把它放在容器视图中……但不应该需要这样做!