enter image description here我在集合视图单元格的UIView内有一个UIImageView,但是即使我做了所有约束(上,下,左,右),图像的高度也比其 super 视图大。
我该如何解决?
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width:DeviceSize.screenWidth - 32, height: DeviceSize.screenWidth/2)
}
最佳答案
组,
imageView.contentMode = .scaleAspectFit //you can change it as per your requirement..
imageView.clipToBounds = true
除了以编程方式进行操作外,您还可以在
storyboard
本身中进行设置,即