Reputation: 8320
Scroll indicators in UICollectionView
starts after from some points from top and ends before that many points from bottom. I mean it has top and bottom margin from UICollectionView
's top and bottom.
Should not it start from top and end at bottom of UICollectionView
?
I checked that contentInset.top
on UICollectionView
and sectionInset.top
on UICollectionViewFlowLayout
are 20.0
and 0.0
, respectively.
See below image. Content start from more than 20.0
pts(which is top inset value) from top.
Upvotes: 1
Views: 4757
Reputation: 544
Building on @kolbasek's answer, this other question's answer shows how to correct it in Storyboard editor ("...select the ViewController, and then untick 'Adjust Scroll View Insets'")
Upvotes: 1
Reputation: 81
problem in translucent status bar and in your case also nav bar
if your collectionView starts right under nav bar when rendering to it added value to the top of the physical screen (64)
In its Projects I encountered a curious situation. A nav bar off translucency, but as soon as I hide it in one of the screens, then added to collectionView magic 20 pixels. Yes, yes, this is a translucent status bar had to take advice Geek
Upvotes: 2
Reputation: 8320
I solved by setting value of below properties to UIEdgeInsetsZero
,
// Set contentInset and scrollIndicatorInset to UIEdgeInsetsZero.
self.tournamentCollection.contentInset = UIEdgeInsetsZero;
self.tournamentCollection.scrollIndicatorInsets = UIEdgeInsetsZero;
Value of contentInset.top
and scrollIndicatorInsets.top
was 64.0
. Similarly for bottom
. It was causing the contents to start 64.0
pts from top.
Note that you should check above properties' values only after layout pass is executed, otherwise you might get 0.0
as a value. This was the case with me. You should check in viewDidLayoutSubview:
methods.
Upvotes: 4