如何在uicollectionview中放大单元格的内容

How to zoom in the content of cell in uicollectionview

在上图中,A、B、C、D、E 是集合视图的每个自定义单元格,我想像 c 单元格一样一个一个地放大单元格。

有什么建议吗?

当你的collectionviewcell点击时调用这个方法

[self animateZoomforCell:cell]; // pass cell as collectionviewcell

-(void)animateZoomforCell:(UICollectionViewCell*)zoomCell
{
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        zoomCell.transform = CGAffineTransformMakeScale(1.6,1.6);
    } completion:^(BOOL finished){
    }];
}
-(void)animateZoomforCellremove:(UICollectionViewCell*)zoomCell
{
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        zoomCell.transform = CGAffineTransformMakeScale(1.0,1.0);
    } completion:^(BOOL finished){
    }];
}

swift3基于Himanshu Moradiya解决方案:

 func animateZoomforCell(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
                        zoomCell.transform = CGAffineTransform.init(scaleX: 1.2, y: 1.2)
            },
    completion: nil)
}
func animateZoomforCellremove(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
            zoomCell.transform = CGAffineTransform.init(scaleX: 1.0, y: 1.0)
    },
        completion: nil)

}