Swift 如何在didSelectItemAtIndexPath中的子类UICollectionViewCell上更改UIImageView的帧

Swift 如何在didSelectItemAtIndexPath中的子类UICollectionViewCell上更改UIImageView的帧,swift,uicollectionviewcell,Swift,Uicollectionviewcell,我在didSelectItemAtIndexPath方法中有以下代码行: var cell = collectionView.cellForItemAtIndexPath(indexPath) as! ParallaxCollectionViewCell cell.imageView.image = UIImage(named: "8") 我可以更改所选单元格的imageView的内容。不过我想更改的是imageView的框架。但是,所有设置都将被忽略。有人知道为什么吗?您使用的是自动

我在didSelectItemAtIndexPath方法中有以下代码行:

var cell = collectionView.cellForItemAtIndexPath(indexPath) as! ParallaxCollectionViewCell
    cell.imageView.image = UIImage(named: "8")

我可以更改所选单元格的imageView的内容。不过我想更改的是imageView的框架。但是,所有设置都将被忽略。有人知道为什么吗?

您使用的是自动布局吗?因为如果是,自动布局约束将覆盖您在代码中所做的任何更改。听起来像是自动布局。