UICollectionView cell subviews do not resize

后端 未结 10 1741
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 00:25

In a CollectionView, some cells should have an additional subview or layer. The CollectionView can be told to resize it\'s cells, thus all content

10条回答
  •  我在风中等你
    2020-11-29 00:49

    I always prefer autolayout when possible. But Sometimes usings frames and bounds just is a timesaver when a view is determined straightforward by only its superview.

    In the case of UICollectionViewCell I set an image to be the cells frame + self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    But when I had different sizes of cells in the collectionView it messed up things and the image sometimes took the size of a different cell.

    So I turned to working with the the cells bounds and - ye that acually worked out fine.

    So maybe give that a try?

提交回复
热议问题