Reputation: 1801
When I add a subview below a UICollectionView, sometimes the subview shows up above the UICollectionView cells. Here is the subview insertion code:
[self.collectionView insertSubview:self.garmentView atIndex:0];
Not sure if I'm not following a best practice or otherwise missing something obvious. Any assistance appreciated.
** Edit ** It might be worth noting that this only happens in landscape, when the rightmost cell is zoomed in.
Upvotes: 4
Views: 5475
Reputation: 675
Why not just:
[self.collectionView addSubview:self.garmentView];
[self.collectionView insertSubview:self.garmentView belowSubview:self.collectionView];
Are you using storyboard? What member of class is your controller?
Upvotes: 0
Reputation: 808
I think
self.garmentView.layer.zPosition = -1
[self.collectionView insertSubview:self.garmentView atIndex:0];
will solve your problem. My guess is that it can happen that the collection view cells gets added with a lower index than your garmentView. See this question for a more thorough discussion about subview positions.
Upvotes: 11