UICollectionViewCell出口框架更改动画

时间:2013-09-07 12:02:35

标签: ios ios6 uicollectionview uiviewanimation

我有一个UICollectionView,它使用瀑布式布局来显示不同大小的单元格。每个单元格的高度计算都很好。

我遇到的问题是我必须在每个单元格中更改两个出口(UIImage和UILabel)的大小,我不知道在哪里更改帧大小以防止UICollectionView动画化所述帧大小更改。我尝试在每个单元格的layoutSubviews方法和没有结果的cellForItemAtIndexPath中执行此操作。每次出现包含UICollectionView的视图控制器时,每个单元格中两个出口的帧更改都会被动画化。

仅为cellForItemAtIndexPath中的图像设置框架的示例:

- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView
              cellForItemAtIndexPath:(NSIndexPath *)indexPath {

CVCNewspaper *cell = (CVCNewspaper *)[collectionView dequeueReusableCellWithReuseIdentifier:CELL_IDENTIFIER_NEWSPAPER forIndexPath:indexPath];
BONewspaper *newspaper = [newspapers objectAtIndex:indexPath.row];
CGFloat width = cell.frame.size.width;

// Calculate rect for imageView
CGFloat objectWidth = newspaper.coverNews.imageWidth ? newspaper.coverNews.imageWidth : 180;
CGFloat objectHeight = newspaper.coverNews.imageHeight ? newspaper.coverNews.imageHeight : 100;
CGFloat scaledHeight = floorf(objectHeight / (objectWidth / width));

cell.imageViewCover.frame = CGRectMake(MARGINVIEW, HEADERHEIGHT + 5, width, scaledHeight);

[cell fillCellWithNewspaper:newspaper];

return cell;

}

0 个答案:

没有答案