I have a refresh control added to a collection view. Everything working, but when I set the collectionView.contentInset = UIEdgeInsetsMake(0, 20, 20, 20) the width of the refresh control stays the same but is shifted 20px, so is not centred in the view. The control should be reduced by 40px for it to be correct.
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];
I have tried setting the width manually after adding the view (also in viewWillLayoutSubviews), and playing with autoresizingMask to no avail.
Any ideas? I guess I will need to resort to putting it in a container view...but shouldn't need to!
OK, fixed the problem by not setting collectionView.contentInset. Instead I set on the flowLayout
i.e.
flowLayout.sectionInset = UIEdgeInsetsMake(0, 20, 20, 20);