Behrouz Riahi Behrouz Riahi - 11 months ago 127
iOS Question

How to add the appropriate padding to the UICollectionView?

The background image of my UICollectionView always appears smaller than the UICollectionView in terms of width and height. Here is the picture (The background white color is the whole UICollectionView size):

The content is outside the UICollectionView

As you see from the picture, this causes the content to go outside of the background image. and when I scroll right, this happens (I cleared the background color of the CollectionView):

enter image description here

This is the size inspector of the CollectionView:

collection view size inspector

How can I reduce the size of the cells container inside the CollectionView?

Or what is the proper way to solve this issue?

Answer Source

Look in your screen shot at the bottom section, the View section. Just give the size a bigger X and a smaller Width. Even better, use autolayout to size the collection view relative to its superview.

As for your image, don't make it the background image of the collection view. Just make it an image that's behind the collection view.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download