UICollectionViewCell background image out of cell

时间:2016-07-11 23:14:25

标签: ios iphone uicollectionview

I am trying to use the background property of my collection view cell to display an image. The problem is :

If my image is not squared, to be sure that it is not deformed, I use the .ScaleToFill property, but when I run the picture overflow the cell frame.

Note that the borderline is hide

Is there a way to fix it ?

Thank you !

2 个答案:

答案 0 :(得分:1)

You should set clipToBounds = true

答案 1 :(得分:0)

Okay, never mind.

I just had to add the following line after the background view set.

cell.clipsToBounds = true