Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 465
vm2000 Avatar asked Jul 25 '17 22:07

vm2000


1 Answers

This feels like a total hack, and I hope this is actually a bug that Apple will fix (but I'm seeing it in the Xcode 9 GM so I'm less optimistic) but I was able to fix this on your sample project with:

cell.contentView.insetsLayoutMarginsFromSafeArea = false

In an app with more complex layouts, I've also had to apply this to subviews that use layout margin guides.

This probably has unintended consequences and will look like a very bad answer in a week. I suspect if you support rotation, this might screw things up.

like image 59
Kevin Avatar answered Sep 19 '22 03:09

Kevin