iOS 11 beta UICollectionViewCell resizes as it approaches top bar using contentInsetAdjustmentBehavior

Viewed 1388

My app has a UIViewController with a container view that fills the entire screen. The container view embeds a UICollectionViewController. These view controllers should scroll under and show through below the status bar. In order to achieve this, I've set the UICollectionViewController.contentInsetAdjustmentBehavior = .never. As I scroll the collectionview and the top of cells scroll under the status bar, the contents of the cell shrink. This is incorrect. I just want them to scroll under the status bar as they did in iOS 10.3.

I have developed a small test app that exhibits my bug and uploaded it as a bug report. It looks so broken that I can't imagine how others haven't see the same issue.

Small test project here: https://github.com/murthyveda2000/ios11bug

3 Answers

In case anyone else is searching, you can also achieve this from within a Storyboard by unchecking Safe Area Relative Margins from the Size Inspector of the selected view in question.

Screenshot of the Safe Area Relative Margins setting in Storyboard

I had the same issue and figured it out based on your sample.

Probably during constraints creation you put top constraint to top with margin. All you need to do is uncheck Relative to margin for the top constraint of the ImageView and everything should work fine.

Screenshot here: https://i.stack.imgur.com/f4hsu.png

Don't forget to change Min spacing For Lines in your collection view to see even the bottom space under items.

Related